﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using miniBoxClassLibrary;
using System.Data;
using Newtonsoft.Json;
using System.Collections;
using System.Security.Cryptography;
using System.Text;

namespace WebService1
{
    class workorder_table
    {
        public string _workorder_id;
        public string _update_time;
        public string _order_status;
        public ArrayList body;
        //public workorder_box_table[] body;
    }
    class workorder_box_table
    {
        public string _box_id;
        public string _box_desc;
        public string _box_first_image;
    }
    class boxes_table
    {
        public string _boxno;
        public string _boxdesc;
        public IList<boxcontent_table> _body;
    }
    class boxcontent_table
    {
        public string _item_image;
        public string _item_type;
        public string _item_desc;
    }

    class invite_table
    {
        public string _accountid;
        public IList<invite_content> _body;
    }

    class invite_content
    {
        public string _referer_info;
    }

    class workorder1_table
    {
        public string _account_id;
        public string _source;
        public string _expect_date1;
        public string _expect_date2;
        public string _mobileno;
        public string _telno;
        public string _province;
        public string _city;
        public string _addr;
        public string _zipcode;
        public bool _isaddaddr;
        public IList<orderdetail_table> _body;
    }
    class orderdetail_table
    {
        public string productname;
        public string quantity;
        public string price;
        public string sub_total;
        public string note;
    }

    /// <summary>
    ///Service1 的摘要描述
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用ASP.NET AJAX 从指令码呼叫此Web 服务，请取消注解下一行。
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {
        private APUtil.clsDataSrc oDataSrc;
        private miniBoxClassLibrary.clsDataSrc_cshap oDataSrc1;
        private APUtil.clsLog oLog = new APUtil.clsLog();
        private miniBoxClassLibrary.SendVerifyCode oSend = new SendVerifyCode();
        private miniBoxClassLibrary.clsCryptoUtil_cshap oclsCryptoUtil = new clsCryptoUtil_cshap();
        private miniBoxClassLibrary.RandomPassword randompwd = new RandomPassword();

        [WebMethod]
        public string HelloWorld(String inTxt)
        {
            string aa = "2014/08/08";
            string[] tempaa = aa.Split('/');
            string y = tempaa[0];
            oDataSrc1 = new clsDataSrc_cshap();
            DataTable a = oDataSrc1.Get_SMSDATA();
            if (a.Rows.Count > 0)
            {
                string mobileno = a.Rows[0].ItemArray[0].ToString().Trim().ToUpper();
                string sms_body = a.Rows[0].ItemArray[1].ToString().Trim().ToUpper();
            }
            String ClientIP = HttpContext.Current.Request.UserHostAddress;
            string resu = randompwd.GetRandomPassword(8);
            string SMS_UID = "cf_shdls";
            string encrypt_uid = "";
            string SMS_PWD = "a123456";
            string encrypt_pwd = "";
            encrypt_uid = APUtil.clsCryptoUtil.Encrypt(SMS_UID.Trim());
            encrypt_pwd = APUtil.clsCryptoUtil.Encrypt(SMS_PWD.Trim());
            String s = "";
            MemberClass mc = new MemberClass();
            string sSMSBody = string.Empty;
            string sResult = string.Empty;
            String today = DateTime.Now.ToString("yyyy-MM-dd");
            String sToday_Y = DateTime.Now.ToString("yyyy");
            String sToday_M = DateTime.Now.ToString("MM");
            String sToday_D = DateTime.Now.ToString("dd");
            string sCheckCode = string.Empty;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                VerifyCode checkcode = new VerifyCode();
                sCheckCode = checkcode.CheckCode(6);
                sSMSBody = "尊敬的用户：您于" + sToday_Y + "年" + sToday_M + "月" + sToday_D + "日申请了手机号码注册，校验码是" + sCheckCode + "，请于30分钟之内完成注册。";
                oDataSrc.GenerateCheckCode(inTxt, 1, sCheckCode);  //产生会员激活验证码
                sResult = oSend.sendSMS("耀民", inTxt, sCheckCode, sSMSBody);  //发送SMS会员激活验证码
                if (sResult == "code:2,msg:提交成功")
                { sResult = "0"; }
                else
                {
                    String[] strSplit = sResult.Split(',');
                    if (strSplit.Length > 0)
                    {
                        sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                        string sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                    }
                }
                s = oLog.writeLine("", "", ClientIP, "JsonData", APUtil.clsLog.enumMsgType.General, "HelloWorld");
                if (s != "0") return s;
                return "sResult: " + sResult ;
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }

        }


        /// <summary>
        /// 取得会员ID
        /// </summary>
        /// <param name="VerifyType">认证方式(0:电邮/1:手机)</param>
        /// <param name="VerifyValue">输入电邮或手机</param>
        /// <returns></returns>
        [WebMethod(Description = "取得会员ID")]
        public string Get_Accountid(int VerifyType, String VerifyValue)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String sID = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            oLog.writeLine("取得会员ID", "", fromIP, "Get_ACCOUNTID(取得会员ID)", APUtil.clsLog.enumMsgType.General, "VerifyType:" + VerifyType + ",VerifyValue:" + VerifyValue);
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                sID = oDataSrc1.Get_ACCOUNTID(VerifyType, VerifyValue);
                sResult = "0";
                if (sID == "") { sMsg = "ID not found!"; }
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得会员ID", "", fromIP, "Get_ACCOUNTID(取得会员ID)", APUtil.clsLog.enumMsgType.General, sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc1 = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""ID"" : """ + sID + @""",";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("取得会员ID", "", fromIP, "Get_ACCOUNTID(取得会员ID)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
            return sJson_Tmp;
        }

        [WebMethod(Description = "取得会员EMAIL")]
        public string Get_ACCOUNTEmail(string accountid, string logintype, string sToken,string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String sEMAIL = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            oLog.writeLine("取得会员EMAIL", "", fromIP, "Get_ACCOUNTEmail(EMAIL)", APUtil.clsLog.enumMsgType.General, "ID:" + accountid + ",logintype:" + logintype + ",sToken:" + sToken);
            //if (usrip == "" || accountid == "" || sToken == "" || logintype == "")
            //{
            //    mc.sResult_Value = "-3";
            //    mc.sMsg_Value = "缺少必填参数";
            //    sJson_Tmp = " {";
            //    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            //    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            //    sJson_Tmp = sJson_Tmp + "}";
            //    return sJson_Tmp;
            //}
            
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                //bResult = oDataSrc1.Check_Token(accountid, logintype, sToken);
                //if (bResult == false)
                //{
                //    mc.sResult_Value = "-2";
                //    mc.sMsg_Value = "TOKEN验证失败";
                //    sJson_Tmp = " {";
                //    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                //    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                //    sJson_Tmp = sJson_Tmp + "}";
                //    return sJson_Tmp;
                //}
                sEMAIL = oDataSrc1.Get_Email(accountid);
                sResult = "0";
                if (sEMAIL == "") { sMsg = "ACCOUNTEmail not found!"; }
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得会员EMAIL", "", fromIP, "Get_ACCOUNTEmail(EMAIL)", APUtil.clsLog.enumMsgType.General, sMsg);
           
            }
            finally
            {
                oDataSrc1 = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""EMAIL"" : """ + sEMAIL + @""",";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("取得会员EMAIL", "", fromIP, "Get_ACCOUNTEmail(EMAIL)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }


        /// <summary>
        /// 加入会员Web Service
        /// </summary>
        /// <param name="cname">姓名</param>
        /// <param name="email">电邮</param>
        /// <param name="mobileno">手机</param>
        /// <param name="pwd">密码</param>
        /// <param name="verifytype">认证方式(0:电邮/1:手机)</param>
        /// <param name="regip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "加入会员Web Service")]
        public string Reg_Member(String cname, String email, String mobileno, String pwd, int verifytype, String regip, String birthday, String sex, String REFERER)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String sCheckCode = string.Empty;
            String sMailBody = string.Empty;
            String sSMSBody = string.Empty;
            String sSubject = string.Empty;
            String sKey = string.Empty;
            String today = DateTime.Now.ToString("yyyy-MM-dd");
            String sToday_Y = DateTime.Now.ToString("yyyy");
            String sToday_M = DateTime.Now.ToString("MM");
            String sToday_D = DateTime.Now.ToString("dd");
            String sToday_H = DateTime.Now.ToString("HH");
            String sToday_m = DateTime.Now.ToString("mm");
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new miniBoxClassLibrary.clsDataSrc_cshap();
                MemberClass mc = new MemberClass();
                sKey = mc.sKey_Value;
                //String s1 = oclsCryptoUtil.MD5Encrypt(pwd, sKey);
                //String s2 = oclsCryptoUtil.MD5Decrypt(s1, sKey);
                oDataSrc.BeginTrans();
                VerifyCode checkcode = new VerifyCode();
                sCheckCode = checkcode.CheckCode(6);
                //write log
                oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "NAME:"+cname + ",EMAIL:" + email + ",MOBILENO:" + mobileno + ",PASSWORD:" + pwd + ",VERIFYTYPE:" + verifytype + ",REGIP:" + regip +",BIRTHDAY:" + birthday + ",SEX:" + sex + ",REFERER:" + REFERER);
                sResult = oDataSrc.AddMember(cname, email, mobileno, pwd, verifytype, regip, birthday, sex, REFERER);
                if (sResult != "0")
                {
                    if (sResult == "1") { sMsg = "手机号码已存在"; }
                    else if (sResult == "2") { sMsg = "电邮已存在"; }
                    else { throw new Exception(sResult); }
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                
                if (verifytype == 0)   //VerifyType = 0 EMAIL / 1 Mobile_No
                {
                    sSubject = "迷你储存-账号申请提醒";
                    sMailBody = "亲爱的" + cname + "先生/女士：";
                    sMailBody = sMailBody + "</br><p>您好！";
                    sMailBody = sMailBody + "</br>迷你仓储已经收到您的注册信息。";
                    sMailBody = sMailBody + "</br>请点击以下确认链接，立即激活账户：";
                    sMailBody = sMailBody + "</br><a href='" + mc.sMember_Active_Url_Value + "'>" + mc.sMember_Active_Url_Value + "</a>";
                    sMailBody = sMailBody + "</br>这是您的激活认证码:" + sCheckCode ;
                    sMailBody = sMailBody + "</br>如果您在使用过程中遇到任何问题，您可以发邮件给我";
                    sMailBody = sMailBody + "</br>们：" + mc.sMailFromAddress_Value + "或者拨打我们的服务专线：<a href='"+mc.sService_TelNo_Value+"'>"+ mc.sService_TelNo_show_Value + "</a>";
                    sMailBody = sMailBody + "</br>与我们联系，我们会尽快为您解决。";
                    sMailBody = sMailBody + "</br></br>这是一封系统自动发送的邮件，请勿回复。";
                    sMailBody = sMailBody + "</br></br>迷你储存";
                    sMailBody = sMailBody + "</br>" + today;
                    sResult = oDataSrc.GenerateCheckCode(email, verifytype, sCheckCode); //产生会员激活验证码
                    oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "寫入会员激活验证码:" + sResult) ;
                    
                    sResult = oSend.sendMail(email, sCheckCode, sMailBody, sSubject);  //发送电​​邮会员激活验证码
                    oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "发送电​​邮会员激活验证码:" + sResult);
                    oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "sSubject:" + sSubject + ",sMailBody:" + sMailBody + ",sCheckCode:"+sCheckCode);
                    if (sResult != "0")
                    {  
                        oDataSrc.Rollback();
                        oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "oDataSrc.Rollback():" + sResult);
                        sJson_Tmp = " {";
                        sJson_Tmp = sJson_Tmp + @"""Status"" : """ + "-1" + @""",";
                        sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sResult + @""" ";
                        sJson_Tmp = sJson_Tmp + "}";
                        oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                        return sJson_Tmp;
                    }
                   
                }
                else
                {
                    sSMSBody = "尊敬的用户：您于" + sToday_Y + "年" + sToday_M + "月" + sToday_D + "日"+ sToday_H +"时"+ sToday_m +"分申请了手机号码注册，校验码是" + sCheckCode + "，请于30分钟之内完成注册。";
                    oDataSrc.GenerateCheckCode(mobileno, verifytype, sCheckCode);  //产生会员激活验证码
                    oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "sSMSBody:" + sSMSBody  + ",sCheckCode:" + sCheckCode);

                    //待傳送簡訊寫入資料庫
                    sResult = oDataSrc1.add_sms(mobileno, sSMSBody);
                    if (sResult != "0")
                    {
                        oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫失敗: " + sResult);
                    }
                    else
                    {
                        oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫成功 " );
                    }
                    
                    sResult = oSend.sendSMS(cname, mobileno, sCheckCode, sSMSBody);  //发送SMS会员激活验证码
                    if (sResult == "code:2,msg:提交成功")
                    { 
                        sResult = "0";
                        oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "发送SMS会员激活验证码成功");
                    
                    }
                    else
                    {
                        oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "发送SMS会员激活验证码失敗:" + sResult);
                        String[] strSplit = sResult.Split(',');
                        if (strSplit.Length > 0)
                        {
                            sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                            sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                        }
                    }
                }
                oDataSrc.Commit();
                oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "完成oDataSrc.Commit()");
                if (REFERER != "")
                {
                    //通知業務員,發出通知信
                    oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "通知業務員,發出通知信:" + REFERER);
                    string account_id = oDataSrc1.Get_ACCOUNTID(0, REFERER);
                    string from_user = oDataSrc.GETCNAME(account_id);
                    sSubject = "迷你儲存-成功邀请朋友";
                    sMailBody = "亲爱的" + from_user + "先生/女士： ";
                    sMailBody = sMailBody + "</br><p>您邀请的" + REFERER + "已成功加入迷你储存！感谢您的邀请！";
                    sMailBody = sMailBody + "</br>希望您可以邀请更多的伙伴一起加入我们！您会获得更多的现金或免费的额度哦。";
                    sMailBody = sMailBody + "</br>您邀请一个新客户成功使用迷你储存，就可以获得1个迷你储存专用箱2个月的使用权，或者是给您该客户在迷你储存使用费的12%";
                    sMailBody = sMailBody + "</br>（三年之内）的现金奖励。";
                    sMailBody = sMailBody + "</br>越多邀请，越多实惠！";
                    sMailBody = sMailBody + "</br>去迷你储存<a href='http://www.minichucun.com'>www.minichucun.com</a>看看！有惊喜噢！！！";
                    sMailBody = sMailBody + "</br>感谢您的邀请！</p>";
                    sMailBody = sMailBody + "</br></br></br></br>";
                    sMailBody = sMailBody + "</br><p><a href='http://weixin.qq.com/r/TnVIUFfEggr9rRMz9yBc'><img src='http://60.248.34.96:8080/web/images/QRcode-mail-105px-wechat.png' alt='关注迷你储存' height='105' width='105'></a></p>";
                    sMailBody = sMailBody + "</br></br></br></br>";
                    sMailBody = sMailBody + "</br><p>这是一封系统自动发送的邮件，请勿回复。<p>";
                    sMailBody = sMailBody + "</br></br></br><p>迷你储存<p>";
                    sMailBody = sMailBody + "</br></br><p>" + DateTime.Now.ToString("yyyy-MM-dd") + "<p>";

                    sResult = oSend.sendMail(REFERER, "", sMailBody, sSubject); //发送电​​邮
                    oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "通知業務員,發出通知信 => sSubject:" + sSubject + ",sMailBody:" + sMailBody + ",邀请人:" + from_user);
                }

            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("加入会员", "", fromIP, "REG_MEMBER(加入会员)", APUtil.clsLog.enumMsgType.General, "進入Exception" + sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("加入会员", "", fromIP, "Reg_Member(加入会员)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 会员激活Web Service
        /// </summary>
        /// <param name="verifytype">认证方式(0:电邮/1:手机)</param>
        /// <param name="verifyvalue">输入手机或电邮</param>
        /// <param name="checkcode">证证码</param>
        /// <param name="verifyip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "会员激活Web Service")]
        public string Active_Member(int verifytype, String verifyvalue, String checkcode, String verifyip)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String sCheckCode = string.Empty;
            String sMailBody = string.Empty;
            String sSubject = string.Empty;
            String cname = string.Empty;
            String sSMSBody = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new miniBoxClassLibrary.clsDataSrc_cshap();
                oDataSrc.BeginTrans();
                oDataSrc1.BeginTrans();
                MemberClass mc = new MemberClass();
                //write log
                oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "VERIFYTYPE: " + verifytype + ",VERIFYVALUE: " + verifyvalue + ",CHECKCODE:" + checkcode + ",VERIFYIP:" + verifyip);
                sResult = oDataSrc.ActiveMember(verifytype, verifyvalue, checkcode, verifyip);
               
                if (sResult == "0")
                {
                    cname = oDataSrc.GETCNAME(verifytype, verifyvalue);
                    if (verifytype == 0)
                    {
                        sSubject = "迷你储存-账号注册成功提醒";
                        sMailBody = "尊敬的" + cname + "先生/女士，您好!";
                        sMailBody = sMailBody + "</br><p>欢迎您成为迷你储存用户！</p>";
                        sMailBody = sMailBody + "</br><p>我们将为您提供一种优雅的都市生活方式，帮助您改善都市居住环境。</p>";
                        sMailBody = sMailBody + "</br><p>迷你储存，您私人的储存空间，留个空间给您自己</p>";
                        sMailBody = sMailBody + "</br><p>您可以登录网页 http://www.minichucun.com开启您都市优雅生活。</p>";
                        sResult = oSend.sendMail(verifyvalue, sCheckCode, sMailBody, sSubject);  //发送电​​邮会员激活验证码
                        if (sResult != "0")
                        {
                            oDataSrc.Rollback();
                            sMsg = sResult;
                            sResult = "-3";
                            sJson_Tmp = " {";
                            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                            sJson_Tmp = sJson_Tmp + "}";
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                            return sJson_Tmp;
                        }
                        else
                        {
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "VERIFYVALUE: " + verifyvalue + ",CHECKCODE:" + checkcode + ",sSubject:" + sSubject + ",sMailBody:" + sMailBody);
                        }
                    }
                    else
                    {
                        sSMSBody = "尊敬的用户：欢迎您加入迷你储存，您的手机号码已经注册成功，详情请登录" + mc.sLogin_Url_Value + "查询。";
                        //cname = oDataSrc.GETCNAME(verifytype, verifyvalue);
                        //待傳送簡訊寫入資料庫
                        sResult = oDataSrc1.add_sms(verifyvalue, sSMSBody);
                        if (sResult != "0")
                        {
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫失敗: " + sResult);
                        }
                        else
                        {
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫成功 ");
                        }

                        oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "Send SMS Start: "+ "sSMSBody:" + sSMSBody + ",sCheckCode" + sCheckCode);
                        sResult = oSend.sendSMS(cname, verifyvalue, sCheckCode, sSMSBody);  //发送SMS会员激活验证码
                        if (sResult == "code:2,msg:提交成功")
                        { 
                            sResult = "0";
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "发送SMS会员激活验证码成功");
                        }
                        else
                        {
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "发送SMS会员激活验证码失敗:" + sResult);
                            String[] strSplit = sResult.Split(',');
                            if (strSplit.Length > 0)
                            {
                                sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                                sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                            }
                            oDataSrc.Rollback();
                            sJson_Tmp = " {";
                            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                            sJson_Tmp = sJson_Tmp + "}";
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                            return sJson_Tmp;
                        }
                    }
                    //初始化會員帳戶餘額
                    String sId = oDataSrc1.Get_ACCOUNTID(verifytype, verifyvalue);
                    sResult = oDataSrc1.init_AccBanalance(sId);
                    if (sResult != "0")
                    {
                        oDataSrc1.RollBack();
                        sMsg = "初始化会员帐户余额失败";
                        sJson_Tmp = " {";
                        sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                        sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                        sJson_Tmp = sJson_Tmp + "}";
                        oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                        return sJson_Tmp;
                    }
                }
                else
                {
                    if (sResult == "1") { sMsg = "会员已激活,不需再次激活"; }
                    else if (sResult == "2") { sMsg = "已逾激活时限，请重新申请校验码"; }
                    else if (sResult == "3") { sMsg = "校验码比对错误"; }
                    else if (sResult == "-2") { sMsg = "会员账号不存在"; }
                    else { throw new Exception(sResult); }
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    oDataSrc.Rollback();
                    return sJson_Tmp;
                }
                oDataSrc.Commit();
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, sMsg);
                oDataSrc.Rollback();
                oDataSrc1.RollBack();
            }
            finally
            {
                oDataSrc = null;
                oDataSrc1 = null;
            }

            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 重送验证码
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "重送验证码")]
        public string CheckCodeReSend(string id, string usrip)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String sCheckResult = string.Empty;
            String[] sTmp = null;
            String sMailBody = string.Empty;
            String sSubject = string.Empty;
            String sCheckCode = string.Empty;
            String sVerifyType = string.Empty;
            String sVerifyValue = string.Empty;
            String sCname = string.Empty;
            String today = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            String sToday_Y = DateTime.Now.ToString("yyyy");
            String sToday_M = DateTime.Now.ToString("MM");
            String sToday_D = DateTime.Now.ToString("dd");
            String sTOday_H = DateTime.Now.ToString("HH");
            String sTOday_m = DateTime.Now.ToString("mm");
            String sTOday_s = DateTime.Now.ToString("ss");
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new clsDataSrc_cshap();
                MemberClass mc = new MemberClass();
                VerifyCode checkcode = new VerifyCode();
                //sCheckResult = oDataSrc1.ACCOUNT_STATUS_CHECK(id);  //确认帐号是否已激活
                sCheckResult = oDataSrc.ACCOUNT_STATUS_CHECK(id);   //确认帐号是否已激活
                oLog.writeLine("重送验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, "确认帐号是否已激活:" + sCheckResult);
                if (sCheckResult != "0")
                {
                    if (sCheckResult == "1") { sMsg = "已完成认证,不需重发验证码 "; }
                    if (sCheckResult == "-2") { sMsg = "CLOSE "; }
                    if (sCheckResult == "-3") { sMsg = "Suspended "; }
                    sResult = sCheckResult;
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("重发验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                sCheckResult = oDataSrc.ACCOUNT_ISLOCKED_CHECK(id); //确认帐号是否已锁定
                oLog.writeLine("重送验证码", "", fromIP, "CheckCodeReSend", APUtil.clsLog.enumMsgType.General, "确认帐号是否已锁定:" + sCheckResult);
                if (sCheckResult == "Y")
                {
                    sResult = "-5";
                    sMsg = "帐号已锁定,请洽客户服务人员";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("重发验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, "return:"+ sJson_Tmp);
                    return sJson_Tmp;
                }
                //sCheckResult = oDataSrc.EXPIRETIME_CHECK(id);    //确认验证码时限是否已超过
                sCheckResult = oDataSrc1.EXPIRETIME_CHECK(id);
                oLog.writeLine("重送验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, "确认验证码时限是否已超过:" + sCheckResult);
                sVerifyType = oDataSrc.GETVERIFYTYPE(id);
                sVerifyValue = oDataSrc.GETVERIFYVALUE(id, sVerifyType);
                sCname = oDataSrc.GETCNAME(id);
                if (sCheckResult == "2")
                {
                    //超过时限内重发次数,需等待时限后申请重发验证码
                    sResult = "-4";
                    sMsg = "超过时限内重发次数,需等待时限后申请重发验证码";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("重发验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;

                }
                else if (sCheckResult == "0")
                {
                    //已逾激活时限,可重新申请验证码
                    sCheckCode = checkcode.CheckCode(6);
                    sResult = oDataSrc.CheckCodeReSend(id, sCheckCode, sCheckResult);
                    if (sVerifyType == "0")
                    {
                        //发送电​​邮会员激活验证码
                        sSubject = "迷你储存会员激活认证码通知信";
                        sMailBody = "亲爱的" + sCname + "会员您好:";
                        sMailBody = sMailBody + "</br><p>感谢您申请成为迷你储存会员,这是您的激活认证码:" + sCheckCode + ",为确认您的电邮帐号无误";
                        sMailBody = sMailBody + "当您收到此认证信后,点击后方网址输入您的激活认证码,激活您的会员帐号</p>";
                        sMailBody = sMailBody + "</br><a href='" + mc.sMember_Active_Url_Value + "'>前往激活网址</a>";
                        sResult = oSend.sendMail(sVerifyValue, sCheckCode, sMailBody, sSubject);
                    }
                    else
                    {
                        string sSMSBody = "尊敬的用户：您于"+ sToday_Y + "年" + sToday_M +"月" + sToday_D + "日" + sTOday_H + "时" + sTOday_m + "分申请了手机号码注册，校验码是" + sCheckCode + "，请于30分钟之内完成注册。";
                        oLog.writeLine("重送验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, "sSMSBody:" + sSMSBody );

                        //待傳送簡訊寫入資料庫
                        sResult = oDataSrc1.add_sms(sVerifyValue, sSMSBody);
                        if (sResult != "0")
                        {
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫失敗: " + sResult);
                        }
                        else
                        {
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫成功 ");
                        }
                        
                        sResult = oSend.sendSMS(sCname, sVerifyValue, sCheckCode, sSMSBody);  //发送SMS会员激活验证码
                        if (sResult == "code:2,msg:提交成功")
                        { sResult = "0"; }
                        else
                        {
                            String[] strSplit = sResult.Split(',');
                            if (strSplit.Length > 0)
                            {
                                sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                                sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                            }
                            oDataSrc.Rollback();
                            sJson_Tmp = " {";
                            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                            sJson_Tmp = sJson_Tmp + "}";
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                            return sJson_Tmp;
                        }
                    }

                }
                else
                {
                    //未超过重发次数
                    if (sCheckResult != "")
                    {
                        sTmp = sCheckResult.Split(',');
                        String s1 = sTmp[0];  //sResult
                        String s2 = sTmp[1];  //VERIFY_CODE
                        sResult = oDataSrc.CheckCodeReSend(id, s2, s1);
                        if (sVerifyType == "0")
                        {
                            //发送电​​邮会员激活验证码
                            sSubject = "迷你储存会员激活认证码通知信";
                            sMailBody = "亲爱的" + sCname + "会员您好:";
                            sMailBody = sMailBody + "</br><p>感谢您申请成为迷你储存会员,这是您的激活认证码:" + s2 + ",为确认您的电邮帐号无误";
                            sMailBody = sMailBody + "当您收到此认证信后,点击后方网址输入您的激活认证码,激活您的会员帐号</p>";
                            sMailBody = sMailBody + "</br><a href='" + mc.sMember_Active_Url_Value + "'>前往激活网址</a>";
                            sResult = oSend.sendMail(sVerifyValue, s2, sMailBody, sSubject);
                        }
                        else
                        {
                            //SMS傳送(尚未完成)
                            string sSMSBody = "尊敬的用户：您于" + sToday_Y + "年" + sToday_M + "月" + sToday_D + "日" + sTOday_H + "时" + sTOday_m + "分申请了手机号码注册，校验码是" + s2 + "，请于30分钟之内完成注册。";
                            oLog.writeLine("重送验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, "sSMSBody:" + sSMSBody);

                            //待傳送簡訊寫入資料庫
                            sResult = oDataSrc1.add_sms(sVerifyValue, sSMSBody);
                            if (sResult != "0")
                            {
                                oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫失敗: " + sResult);
                            }
                            else
                            {
                                oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫成功 ");
                            }
                            
                            sResult = oSend.sendSMS(sCname, sVerifyValue, s2, sSMSBody);  //发送SMS会员激活验证码
                            if (sResult == "code:2,msg:提交成功")
                            { sResult = "0"; }
                            else
                            {
                                String[] strSplit = sResult.Split(',');
                                if (strSplit.Length > 0)
                                {
                                    sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                                    sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                                }
                                oDataSrc.Rollback();
                                sJson_Tmp = " {";
                                sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                                sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                                sJson_Tmp = sJson_Tmp + "}";
                                oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                                return sJson_Tmp;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("重发验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("重发验证码", "", fromIP, "CheckCodeReSend(重发验证码)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 修改会员基本资料
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="cname">姓名</param>
        /// <param name="email">电邮</param>
        /// <param name="mobileno">手机</param>
        /// <param name="usrip">IP位址</param>
        /// <param name="birthday">生日</param>
        /// <param name="sex">性別</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <returns></returns>
        [WebMethod(Description = "修改会员基本资料")]
        public string Mofidy_MemberProfile(String id, String cname, String email, String mobileno, String usrip, String birthday, String sex, string logintype, string sToken)
        {
            String sMailBody = string.Empty;
            bool bResult = false;
            String sSubject = string.Empty;
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            DataTable dt = new DataTable();
            String sCheckCode = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                oLog.writeLine("修改会员基本资料", "", fromIP, "Mofidy_MemberProfile(修改会员基本资料)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",NAME:"
                    + cname + ", EMAIL:" + email + ", MOBILE_NO:" + mobileno + ", SEX:" + sex + ", BIRTHDAY:" + birthday + ",USRIP:" + usrip + ",logintype:" + logintype + ",sToken:" + sToken);
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("修改会员基本资料", "", fromIP, "Mofidy_MemberProfile(修改会员基本资料)", APUtil.clsLog.enumMsgType.General, "Check_Token => return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                VerifyCode verifycode = new VerifyCode();
                sCheckCode = verifycode.CheckCode(6);
                sSubject = "迷你储存会员激活认证码通知信";
                sMailBody = "亲爱的" + cname + "会员您好:";
                sMailBody = sMailBody + "</br><p>感谢您申请成为迷你储存会员,这是您的激活认证码:" + sCheckCode + ",为确认您的电邮帐号无误";
                sMailBody = sMailBody + "当您收到此认证信后,点击后方网址输入您的激活认证码,激活您的会员帐号</p>";
                sMailBody = sMailBody + "</br><a href='" + mc.sMember_Active_Url_Value + "'>前往激活网址</a>";
                mc.sResult_Value = oDataSrc1.Set_Accounts(id, cname, email, mobileno, sex, birthday, usrip, sMailBody, sSubject, sCheckCode);

                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("修改会员基本资料", "", fromIP, "Mofidy_MemberProfile(修改会员基本资料)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally
            {
                oDataSrc1 = null;
            }
            if (mc.sResult_Value == "1") { mc.sMsg_Value = "电邮或手机已存在,变更失败"; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("修改会员基本资料", "", fromIP, "Mofidy_MemberProfile(修改会员基本资料)", APUtil.clsLog.enumMsgType.General, "return:"+ sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 变更密码
        /// </summary>
        /// <param name="verifytype">认证方式(0:电邮/1:手机)</param>
        /// <param name="verifyvalue">输入手机或电邮</param>
        /// <param name="sNewPwd">新密码</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        //[WebMethod(Description = "变更密码")]
        public string ReSetPwd(String id, String sNewPwd, String logintype, String sToken, String usrip)
        {
            String sResult = string.Empty;
            bool bResult = false;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String sMailBody = string.Empty;
            String sSubject = string.Empty;
            String sCname = string.Empty;
            String sKey = string.Empty;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new clsDataSrc_cshap();
                MemberClass mc = new MemberClass();
                sKey = mc.sKey_Value;
                String s1 = oclsCryptoUtil.MD5Encrypt(sNewPwd, sKey);
                //String s2 = oclsCryptoUtil.MD5Decrypt(s1, sKey);
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    sResult = "-2";
                    sMsg = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }
                //sCname = oDataSrc.GETCNAME(verifytype, verifyvalue);
                sCname = oDataSrc.GETCNAME(id);
                //write log
                oLog.writeLine("變更密碼", "", usrip, "ReSetPwd", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",LOGIN_TYPE:" + logintype + ",TOKEN:" + sToken + ",newPwd:" + sNewPwd + ",usrip:" + usrip);

                if (sCname == "" || sCname == null)
                {
                    sResult = "1";
                    sMsg = "此帳號未註冊";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }
                String verifytype = oDataSrc.GETVERIFYTYPE(id);
                if (Convert.ToInt16(verifytype) == 0)
                {
                    //EMAIL傳送新密碼
                    sSubject = "迷你儲存会员密碼大變更通知信";
                    sMailBody = "親愛的" + sCname + "会员您好:";
                    sMailBody = sMailBody + "</br><p>您的密碼已經變更,如果您沒有變更密碼,請與客服人員聯繫,";
                    sMailBody = sMailBody + "客服人員會協助你回復您的密碼</p>";

                    sResult = oSend.sendMail(oDataSrc.GETVERIFYVALUE(id, verifytype), sNewPwd.Trim(), sMailBody, sSubject);
                    if (sResult != "0") throw new Exception(sResult);
                }
                else
                {
                    //SMS傳送新密碼(尚未完成)
                }
                sResult = oDataSrc.ReSetPwd(id, s1.Trim());
                if (sResult != "0") throw new Exception(sResult);
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("變更密碼", "", usrip, "ReSetPwd", APUtil.clsLog.enumMsgType.General, sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc = null;
            }

            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            return sJson_Tmp;
        }

        /// <summary>
        /// 忘记密码
        /// </summary>
        /// <param name="verifytype">认证方式(0:电邮/1:手机)</param>
        /// <param name="verifyvalue">输入手机或电邮</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "忘记密码")]
        public string ForgetPwd(int verifytype, String verifyvalue, String usrip)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String sNewPwd = string.Empty;
            String sMailBody = string.Empty;
            String sSubject = string.Empty;
            String sCname = string.Empty;
            String sID = string.Empty;
            String sKey = string.Empty;
            String sSMSBody = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                VerifyCode checkcode = new VerifyCode();
                sNewPwd = checkcode.CheckCode(8);
                MemberClass mc = new MemberClass();
                
                sKey = mc.sKey_Value;
                //String s1 = oclsCryptoUtil.MD5Encrypt(sNewPwd, sKey);
                //String s2 = oclsCryptoUtil.MD5Decrypt(s1, sKey);
                sCname = oDataSrc.GETCNAME(verifytype, verifyvalue);
                //write log
                oLog.writeLine("忘记密码", "", fromIP, "ForgetPwd(忘记密码)", APUtil.clsLog.enumMsgType.General, "Verify_Type:" + verifytype + ",Verify_Value:" + verifyvalue + ",newPwd:" + sNewPwd + ",usrip:" + usrip);
                sID = oDataSrc.FindID(verifyvalue, Convert.ToInt16(verifytype));
                if (sCname == "" || sCname == null)
                {
                    sResult = "1";
                    sMsg = "此帐号未注册";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("忘记密码", "", fromIP, "ForgetPwd(忘记密码)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                if (verifytype == 0)
                {
                    //EMAIL传送新密码
                    sSubject = "迷你储存会员密码重设通知信";
                    sMailBody = "亲爱的" + sCname + "会员您好:";
                    sMailBody = sMailBody + "</br><p>这是系统帮您重设的会员密码:" + sNewPwd + ",";
                    sMailBody = sMailBody + "当您收到此通知信后,点击后方网址输入您的新密码,然后重设您的会员密码</p>";
                    sMailBody = sMailBody + "</br><a href='" + mc.sReSetUrl_Value + "'>" + mc.sReSetUrl_Value + "</a>";
                    sResult = oSend.sendMail(verifyvalue, sNewPwd.Trim(), sMailBody, sSubject);
                    oLog.writeLine("忘记密码", "", fromIP, "ForgetPwd(忘记密码)", APUtil.clsLog.enumMsgType.General, "sNewPwd:" + sNewPwd + ",sMailBody:" + sMailBody + ",sSubject:" + sSubject);
                    if (sResult != "0") throw new Exception(sResult);
                }
                else
                {
                    //SMS傳送新密碼
                    sSMSBody = "尊敬的用户：您正在找回登录密码，校验码" + sNewPwd + "，切勿泄露，请前往http://www.minichucun.com 完成密码找回。";
                    //sSMSBody = sSMSBody + "</br><a href='" + mc.sReSetUrl_Value + "'> 完成密碼找回</a>";
                    oLog.writeLine("忘记密码", "", fromIP, "ForgetPwd(忘记密码)", APUtil.clsLog.enumMsgType.General, "sNewPwd:" + sNewPwd + ",sMailBody:" + sMailBody + ",sSubject:" + sSubject);

                    //待傳送簡訊寫入資料庫
                    sResult = oDataSrc1.add_sms(verifyvalue, sSMSBody);
                    if (sResult != "0")
                    {
                        oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫失敗: " + sResult);
                    }
                    else
                    {
                        oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫成功 ");
                    }

                    sResult = oSend.sendSMS(sCname, verifyvalue, sNewPwd, sSMSBody);  //发送SMS会员激活验证码
                    if (sResult == "code:2,msg:提交成功")
                    { sResult = "0"; }
                    else
                    {
                        String[] strSplit = sResult.Split(',');
                        if (strSplit.Length > 0)
                        {
                            sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                            sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                        }
                        oDataSrc.Rollback();
                        sJson_Tmp = " {";
                        sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                        sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                        sJson_Tmp = sJson_Tmp + "}";
                        oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                        return sJson_Tmp;
                    }
                    
                }
                //=======================SHA1========================================
                
                SHA1 hash = SHA1CryptoServiceProvider.Create();
                byte[] plainTextBytes = Encoding.ASCII.GetBytes(sNewPwd);
                byte[] hashBytes = hash.ComputeHash(plainTextBytes);
                string localChecksum = BitConverter.ToString(hashBytes)
                .Replace("-", "").ToLowerInvariant();

                //SHA256 sha256 = new SHA256CryptoServiceProvider();//建立一個SHA256
                //byte[] source = Encoding.Default.GetBytes(sNewPwd);//將字串轉為Byte[]
                //byte[] crypto = sha256.ComputeHash(source);//進行SHA1加密
                //string encoderesult = Convert.ToBase64String(crypto);//把加密後的字串從Byte[]轉為字串
                //===================================================================
                sResult = oDataSrc.ReSetPwd(sID, localChecksum.Trim());
                if (sResult != "0") throw new Exception(sResult);
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("忘记密码", "", fromIP, "ForgetPwd(忘记密码)", APUtil.clsLog.enumMsgType.General, sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc = null;
            }

            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("忘记密码", "", fromIP, "ForgetPwd(忘记密码)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 会员登入
        /// </summary>
        /// <param name="verifytype">认证方式(0:电邮/1:手机)</param>
        /// <param name="verifyvalue">手机或电邮</param>
        /// <param name="pwd">密码</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "会员登入")]
        public string MemberLogon(int verifytype, string verifyvalue, string pwd, string logintype, string usrip)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String sID = string.Empty;
            String sToken = string.Empty;
            String sKey = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new clsDataSrc_cshap();
                MemberClass mc = new MemberClass();
                sKey = mc.sKey_Value;
                //String s1 = oclsCryptoUtil.MD5Encrypt(pwd, sKey);
                oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "Verify_Type:" + verifytype + "," + "Verify_Value:" + verifyvalue + ", pwd:" + pwd + ",logintype" + logintype + ",usrip:" + usrip);

                sResult = oDataSrc.MemberLogon(verifytype, verifyvalue, pwd, logintype, usrip);    //执行会员登入
                if (sResult == "1")
                {
                    sResult = "1";
                    sMsg = "帐号未激活";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General,  "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                if (sResult == "5")
                {
                    sResult = "5";
                    sMsg = "登录名错误";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                if (sResult == "3")
                {
                    sResult = "3";
                    sMsg = "帐号被锁定";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                if (sResult == "-3")
                {
                    sResult = "-3";
                    sMsg = "密码错误";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                if (sResult != "0" && sResult != "2") throw new Exception(sResult);
                sID = oDataSrc.FindID(verifyvalue, verifytype);     //如果登入成功,就取回会员ID
                oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "取回会员ID:" + sID);
                sToken = oDataSrc1.Get_Token(sID, logintype);       //取回会员TOKEN
                if (sToken == "")
                {
                    sResult = "-2";
                    sMsg = "取回会员TOKEN为空值,请洽系统管理员处理";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "Verify_Type:" + verifytype + "," + "Verify_Value:" + verifyvalue + ", pwd:" + pwd + ",usrip:" + usrip + ",ID:" + sID);

                if (sID == "" || sID == null)
                {
                    sResult = "1";
                    sMsg = "此帐号未注册";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""ID"" : """ + sID + @""",";
            sJson_Tmp = sJson_Tmp + @"""TOKEN"" : """ + sToken + @""",";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            if(sResult == "2")
                sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @"密码需要更新"" ";
            else
                sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("会员登入", "", fromIP, "MemberLogon(会员登入)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 密码变更
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="newPwd">新密码</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "密码变更")]
        public string ChangePwd(String id, String newPwd, String logintype, String sToken, String usrip)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            bool bResult = false;
            String sKey = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new clsDataSrc_cshap();
                MemberClass mc = new MemberClass();
                sKey = mc.sKey_Value;
                //String s1 = oclsCryptoUtil.MD5Encrypt(newPwd, sKey);
                //String s2 = oclsCryptoUtil.MD5Decrypt(s1, sKey);
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("密码变更", "", fromIP, "ChangePwd(密码变更)", APUtil.clsLog.enumMsgType.General, "id:" + id+",logintype"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    sResult = "-2";
                    sMsg = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("密码变更", "", fromIP, "ChangePwd(密码变更)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                sResult = oDataSrc.ChangePwd(id, newPwd, usrip);
                oLog.writeLine("密码变更", "", fromIP, "ChangePwd(密码变更)", APUtil.clsLog.enumMsgType.General, "id:" + id + "," + "newPwd:" + newPwd + ",logintype" + logintype + "," + "usrip:" + usrip);
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("密码变更", "", fromIP, "ChangePwd(密码变更)", APUtil.clsLog.enumMsgType.General, sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("密码变更", "", fromIP, "ChangePwd(密码变更)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 密码变更
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="oldPwd">旧密码</param>
        /// <param name="newPwd">新密码</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOEKN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "密码变更_v2")]
        public string ChangePwd_v2(String id, String oldPwd, String newPwd, String logintype, String sToken, String usrip)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            bool bResult = false;
            String sKey = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc.BeginTrans();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("密码变更_v2", "", fromIP, "ChangePwd(密码变更_v2)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",logintype:" + logintype +",sToken:"+sToken);
                if (bResult == false)
                {
                    oDataSrc.Rollback();
                    sResult = "-2";
                    sMsg = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("密码变更_v2", "", fromIP, "ChangePwd(密码变更_v2)", APUtil.clsLog.enumMsgType.General, "ID:"+id +",return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                if (oDataSrc1.Compare_oldPwd(oldPwd, id))
                {
                    sResult = oDataSrc.ChangePwd(id, newPwd, usrip);
                    oDataSrc.Commit();
                    oLog.writeLine("密码变更_v2", "", fromIP, "ChangePwd(密码变更_v2)", APUtil.clsLog.enumMsgType.General, "id:" + id + "," + "oldPwd:" + oldPwd + "," + "newPwd:" + newPwd + "," + "usrip:" + usrip);
                }
                else
                {
                    sResult = "-3";
                    sMsg = "旧密码比对错误,密码变更失败.";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("密码变更_v2", "", fromIP, "ChangePwd(密码变更_v2)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("密码变更", "", fromIP, "ChangePwd(密码变更_v2)", APUtil.clsLog.enumMsgType.General,"ID:"+id +",MSG"+ sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc = null;
                oDataSrc1 = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("密码变更_v2", "", fromIP, "ChangePwd(密码变更_v2)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 查询会员基本资料
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "查询会员基本资料")]
        public String Get_MemberProfile(String id, String logintype, String sToken, String usrip)
        {
            String sResult = string.Empty;
            String sMsg = string.Empty;
            String sJson_Tmp = string.Empty;
            String[] split = null;
            String sCNAME = string.Empty;
            String sEMAIL = string.Empty;
            String sMOBILENO = string.Empty;
            String sSEX = string.Empty;
            String sBIRTHDAY = string.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("查询会员基本资料", "", fromIP, "Get_MemberProfile(查询会员基本资料)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",logintype:" + logintype +",sToken:"+ sToken);
                if (bResult == false)
                {
                    sResult = "-2";
                    sMsg = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("查询会员基本资料", "", fromIP, "Get_MemberProfile(查询会员基本资料)", APUtil.clsLog.enumMsgType.General, "Check_Token=> ID:" + id + ",return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                sResult = oDataSrc.GETMemberProfile(id);
                split = sResult.Split(',');
                sCNAME = split[0];
                sEMAIL = split[1];
                sMOBILENO = split[2];
                sSEX = split[3];
                sBIRTHDAY = split[4];
                sResult = "0";
                oLog.writeLine("查询会员基本资料", "", fromIP, "Get_MemberProfile(查询会员基本资料)", APUtil.clsLog.enumMsgType.General, "id:" + id);
            }
            catch (Exception ex)
            {
                sResult = "-1";
                sMsg = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("查询会员基本资料", "", fromIP, "Get_MemberProfile(查询会员基本资料)", APUtil.clsLog.enumMsgType.General, sMsg);
                oDataSrc.Rollback();
            }
            finally
            {
                oDataSrc = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""CNAME"" : """ + sCNAME + @""",";
            sJson_Tmp = sJson_Tmp + @"""EMAIL"" : """ + sEMAIL + @""",";
            sJson_Tmp = sJson_Tmp + @"""MOBILENO"" : """ + sMOBILENO + @""",";
            sJson_Tmp = sJson_Tmp + @"""SEX"" : """ + sSEX + @""",";
            sJson_Tmp = sJson_Tmp + @"""BIRTHDAY"" : """ + sBIRTHDAY + @""",";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("查询会员基本资料", "", fromIP, "Get_MemberProfile(查询会员基本资料)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 新增/修改/刪除常用地址
        /// </summary>
        /// <param name="action">ADD/MODIFY/DELETE (新增/修改/刪除)</param>
        /// <param name="accountid">会员ID</param>
        /// <param name="province">省</param>
        /// <param name="city">市</param>
        /// <param name="zipcode">邮递区号</param>
        /// <param name="addr">地址</param>
        /// <param name="tel_no">家用电话</param>
        /// <param name="mobile_no">手机</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <param name="is_default">是否为默认地址(删除是也要给true or false)</param>
        /// <param name="id">地址ID (选择性参数)</param>
        /// <returns></returns>
        [WebMethod(Description = "新增修改刪除常用地址")]
        public String Set_Adresses(string action, string accountid, string province, string city, string zipcode,
            string addr, string tel_no, string mobile_no, string logintype, string sToken, string usrip, bool is_default = false, string id = "0")
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            DataTable dt = new DataTable();
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                oLog.writeLine("常用地址新增修改刪除", "", fromIP, "Set_Adresses(常用地址新增修改刪除)", APUtil.clsLog.enumMsgType.General,
                    "action:" + action + "," + "accountid:" + accountid + "," + "province:" + province + "," +
                    "city:" + city + "," + "zipcode" + zipcode + "," + "addr:" + addr + "," + "tel_no:" + tel_no +
                    "," + "mobile_no:" + mobile_no + ",is_default:" + is_default.ToString() + "," + "usrip:" +
                    usrip + "," + "id:" + "id");
                bResult = oDataSrc1.Check_Token(accountid, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("常用地址新增修改刪除", "", fromIP, "Set_Adresses(常用地址新增修改刪除)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                if (action.Equals("DELETE")) { is_default = false; }
                mc.sResult_Value = oDataSrc1.Set_Addresses(action, accountid, province, city, zipcode, addr, tel_no, mobile_no, usrip, is_default, id);
                if (mc.sResult_Value == "2")
                {
                    mc.sMsg_Value = "默认地址不可删除";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("常用地址新增修改刪除", "", fromIP, "Set_Adresses(常用地址新增修改刪除)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                if (mc.sResult_Value == "1")
                {
                    mc.sMsg_Value = "ADDRESSID不可为空值";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("常用地址新增修改刪除", "", fromIP, "Set_Adresses(常用地址新增修改刪除)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("常用地址新增修改刪除", "", fromIP, "Set_Adresses(常用地址新增修改刪除)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally
            {
                oDataSrc1 = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("常用地址新增修改刪除", "", fromIP, "Set_Adresses(常用地址新增修改刪除)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 取得常用地址列表
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得常用地址列表")]
        public String Get_Addresses(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得常用地址", "", fromIP, "Get_Addresses(取得常用地址)", APUtil.clsLog.enumMsgType.General, "ID:" + id +",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得常用地址", "", fromIP, "Get_Addresses(取得常用地址)", APUtil.clsLog.enumMsgType.General, "Check_Token => retrun:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Addresses(id, usrip);
                oLog.writeLine("取得常用地址", "", fromIP, "Get_Addresses(取得常用地址)", APUtil.clsLog.enumMsgType.General, "id:" + id);

                if (dt != null)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "ADDRESSES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得常用地址", "", fromIP, "Get_Addresses(取得常用地址)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                else
                {
                    DataTable temp = new DataTable();
                    temp.TableName = "ADDRESSES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得常用地址", "", fromIP, "Get_Addresses(取得常用地址)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                return mc.sResult_Value;
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得常用地址", "", fromIP, "Get_Addresses(取得常用地址)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
                return mc.sMsg_Value;
            }
            finally
            {
                dt = null;
                ds.Dispose();
                ds = null;
                oDataSrc1 = null;
            }
        }

        /// <summary>
        /// 取得默认地址ID
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得默认地址ID")]
        public String Get_DefaultAddressID(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得默认地址ID", "", fromIP, "Get_DefaultAddressID(取得默认地址ID)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得默认地址ID", "", fromIP, "Get_DefaultAddressID(取得默认地址ID)", APUtil.clsLog.enumMsgType.General, "Check_Token => return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                mc.sDefaultAddressID_Value = oDataSrc1.Get_DefaultAddressID(id, usrip);
                mc.sResult_Value = "0";
                oLog.writeLine("取得默认地址ID", "", fromIP, "Get_DefaultAddressID(取得默认地址ID)", APUtil.clsLog.enumMsgType.General, "id:" + id);

            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得默认地址ID", "", fromIP, "Get_DefaultAddressID(取得默认地址ID)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally
            {
                oDataSrc1 = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Default_AddressID"" : """ + mc.sDefaultAddressID_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("取得默认地址ID", "", fromIP, "Get_DefaultAddressID(取得默认地址ID)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 設定默认地址ID
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="default_addrid">地址ID</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "設定默认地址ID")]
        public string Set_DefaultAddressID(string id, string logintype, string sToken, string default_addrid, string usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("設定默认地址ID", "", fromIP, "Set_DefaultAddressID(設定默认地址ID)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("設定默认地址ID", "", fromIP, "Set_DefaultAddressID(設定默认地址ID)", APUtil.clsLog.enumMsgType.General, "Check_Token => return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                mc.sResult_Value = oDataSrc1.Set_DefaultAddressID(id, default_addrid);
                oLog.writeLine("設定默认地址ID", "", fromIP, "Set_DefaultAddressID(設定默认地址ID)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ", default_AddrID:" + default_addrid);
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("設定默认地址ID", "", fromIP, "Set_DefaultAddressID(設定默认地址ID)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("設定默认地址ID", "", fromIP, "Set_DefaultAddressID(設定默认地址ID)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        #region  出仓记录

        /// <summary>
        /// 取得箱内资料
        /// </summary>
        /// <param name="boxid">箱號</param>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得箱内资料")]
        public String Get_BoxContent(string boxid, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得箱内资料", "", fromIP, "Get_BoxContent(取得箱内资料)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得箱内资料", "", fromIP, "Get_BoxContent(取得箱内资料)", APUtil.clsLog.enumMsgType.General, "Check_Token => return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_BOXCONTENT(boxid);
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "BOX_CONTENTS";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得箱内资料", "", fromIP, "Get_BoxContent(取得箱内资料)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                else
                {
                    DataTable temp = new DataTable();
                    temp.TableName = "BOX_CONTENTS";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得箱内资料", "", fromIP, "Get_BoxContent(取得箱内资料)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得箱内资料", "", fromIP, "Get_BoxContent(取得箱内资料)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        [WebMethod(Description = "取得出仓记录(以日期区间或关键字搜寻)")]
        public String Get_PickupData_v2(string id, string logintype, string sToken, string startdate, string enddate, string keyword, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得出仓记录(以日期区间或关键字搜寻)", "", fromIP, "Get_PickupDataByALL(取得出仓记录(以日期区间或关键字搜寻))", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得出仓记录(以日期区间或关键字搜寻)", "", fromIP, "Get_PickupDataByALL(取得出仓记录(以日期区间或关键字搜寻))", APUtil.clsLog.enumMsgType.General, "Check_Token => return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_PickupData(id, startdate, enddate, keyword);
                oLog.writeLine("取得出仓记录(以日期区间或关键字搜寻)", "", fromIP, "Get_PickupDataByALL(取得出仓记录(以日期区间或关键字搜寻))", APUtil.clsLog.enumMsgType.General, "id:" + id + ",startdate:" + startdate + ",enddate:" + enddate + ",keyword:" + keyword + ",usrip:" + usrip);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "ACCOUNT_BOXES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得出仓记录(以日期区间或关键字搜寻)", "", fromIP, "Get_PickupDataByALL(取得出仓记录(以日期区间或关键字搜寻))", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                else
                {
                    DataTable temp = new DataTable();
                    temp.TableName = "ACCOUNT_BOXES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得出仓记录(以日期区间或关键字搜寻)", "", fromIP, "Get_PickupDataByALL(取得出仓记录(以日期区间或关键字搜寻))", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得出仓记录(以日期区间或关键字搜寻)", "", fromIP, "Get_PickupDataByALL(取得出仓记录(以日期区间或关键字搜寻))", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 取得出仓记录(以日期区间搜寻)
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="startdate">起始日期(格式:2014/07/31)</param>
        /// <param name="enddate">結束日期(格式:2014/07/31)</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得出仓记录(以日期区间搜寻)")]
        public String Get_PickupDataByDate(string id, string logintype, string sToken, string startdate, string enddate, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得出仓记录(以日期区间搜寻)", "", fromIP, "Get_PickupDataByDate(取得出仓记录(以日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得出仓记录(以日期区间搜寻)", "", fromIP, "Get_PickupDataByDate(取得出仓记录(以日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "Check_Token => return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_PickupData(id, startdate, enddate);
                oLog.writeLine("取得出仓记录(以日期区间搜寻)", "", fromIP, "Get_PickupDataByDate(取得出仓记录(以日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "id:" + id + ",startdate:" + startdate + ",enddate:" + enddate + ",usrip:" + usrip);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "ACCOUNT_BOXES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得出仓记录(以日期区间搜寻)", "", fromIP, "Get_PickupDataByDate(取得出仓记录(以日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                else
                {
                    DataTable temp = new DataTable();
                    temp.TableName = "ACCOUNT_BOXES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得出仓记录(以日期区间搜寻)", "", fromIP, "Get_PickupDataByDate(取得出仓记录(以日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得出仓记录(以日期区间搜寻)", "", fromIP, "Get_PickupDataByDate(取得出仓记录(以日期区间搜寻))", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 取得出仓记录(BY关键字)
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="keyword">关键字</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得出仓记录(BY关键字)")]
        public String Get_PickupDataByKeyword(string id, string logintype, string sToken, string keyword, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得出仓记录(BY关键字)", "", fromIP, "Get_PickupDataByDate(取得出仓记录(BY关键字))", APUtil.clsLog.enumMsgType.General, "ID:" + id +",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得出仓记录(BY关键字)", "", fromIP, "Get_PickupDataByDate(取得出仓记录(BY关键字))", APUtil.clsLog.enumMsgType.General, "Check_Token => return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_PickupData(id, keyword);
                oLog.writeLine("取得出仓记录(BY关键字)", "", fromIP, "Get_PickupDataByKeyword(取得出仓记录(BY关键字))", APUtil.clsLog.enumMsgType.General, "id:" + id + ",keyword:" + keyword + ",usrip:" + usrip);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "ACCOUNT_BOXES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得出仓记录(BY关键字)", "", fromIP, "Get_PickupDataByKeyword(取得出仓记录(BY关键字))", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                else
                {
                    DataTable temp = new DataTable();
                    temp.TableName = "ACCOUNT_BOXES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得出仓记录(BY关键字)", "", fromIP, "Get_PickupDataByKeyword(取得出仓记录(BY关键字))", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得出仓记录(BY关键字)", "", fromIP, "Get_PickupDataByKeyword(取得出仓记录(BY关键字))", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 取得出仓记录
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得出仓记录")]
        public String Get_PickupData(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得出仓记录", "", fromIP, "Get_PickupData(取得出仓记录)", APUtil.clsLog.enumMsgType.General, "ID:" + id +",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得出仓记录", "", fromIP, "Get_PickupData(取得出仓记录)", APUtil.clsLog.enumMsgType.General, "Check_Token => return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_PickupData(id);
                oLog.writeLine("取得出仓记录", "", fromIP, "Get_PickupData(取得出仓记录)", APUtil.clsLog.enumMsgType.General, "id:" + id + ",usrip:" + usrip);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "ACCOUNT_BOXES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得出仓记录", "", fromIP, "Get_PickupData(取得出仓记录)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                else
                {
                    DataTable temp = new DataTable();
                    temp.TableName = "ACCOUNT_BOXES";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得出仓记录", "", fromIP, "Get_PickupData(取得出仓记录)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得出仓记录", "", fromIP, "Get_PickupData(取得出仓记录)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }


        #endregion


        #region 交易记录


        /// <summary>
        /// 取得订单明细
        /// </summary>
        /// <param name="orderid">订单编号</param>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得订单明细")]
        public String Get_OrderDetail(string orderid, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得订单明细", "", fromIP, "Get_OrderDetail(取得订单明细)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得订单明细", "", fromIP, "Get_OrderDetail(取得订单明细)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_OrderDetail(orderid);
                oLog.writeLine("取得订单明细", "", fromIP, "Get_OrderDetail(取得订单明细)", APUtil.clsLog.enumMsgType.General, "ORDERID:" + orderid + ", USRIP:" + usrip);
                if (dt != null && dt.Rows.Count > 0)
                {
                    dt.TableName = "ORDER_DETAIL";
                    ds.Tables.Add(dt.Copy());
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得订单明细", "", fromIP, "Get_OrderDetail(取得订单明细)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "ORDER_DETAIL";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得订单明细", "", fromIP, "Get_OrderDetail(取得订单明细)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得订单明细", "", fromIP, "Get_OrderDetail(取得订单明细)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 取得交易记录
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得交易记录")]
        public String Get_AccountLedger(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataTable dt1 = new DataTable();
            DataSet ds = new DataSet();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("TOKEN验证", "", fromIP, "Get_AccountBalance_DT", APUtil.clsLog.enumMsgType.General, "ID:" + id + ", LOGINTYPE:" + logintype + ",USRIP:" + usrip);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得交易记录", "", fromIP, "Get_AccountLedger(取得交易记录)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",return: " + sJson_Tmp);
                    return sJson_Tmp;
                }
                dt1 = oDataSrc1.Get_AccountBalance_DT(id);
                oLog.writeLine("取得帐户余额", "", fromIP, "Get_AccountLedger(取得交易记录)", APUtil.clsLog.enumMsgType.General, "Get_AccountBalance_DT => ID:" + id + ", USRIP:" + usrip);
                if (dt1 != null && dt1.Rows.Count > 0)
                {
                    dt1.TableName = "ACCOUNT_BALANCE";
                    ds.Tables.Add(dt1.Copy());
                }
                oLog.writeLine("取得交易记录", "", fromIP, "Get_AccountLedger(取得交易记录)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",USRIP: " + usrip);
                dt = oDataSrc1.Get_AccountLedger(id);
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "ACCOUNT_LEDGER";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得交易记录", "", fromIP, "Get_AccountLedger(取得交易记录)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                else
                {
                    DataTable table1 = new DataTable();
                    DataTable table2 = new DataTable();
                    table1.TableName = "ACCOUNT_BALANCE";
                    table2.TableName = "ACCOUNT_LEDGER";
                    ds.Tables.Add(table1);
                    ds.Tables.Add(table2);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得交易记录", "", fromIP, "Get_AccountLedger(取得交易记录)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                }
                return mc.sResult_Value;
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得交易记录", "", fromIP, "Get_AccountLedger(取得交易记录)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }



        /// <summary>
        /// 取得帐户余额
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得帐户余额")]
        public String Get_AccountBalance(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            double sResult = 0;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得帐户余额", "", fromIP, "Get_AccountBalance(取得帐户余额)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ", LOGINTYPE:" + logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得帐户余额", "", fromIP, "Get_AccountBalance(取得帐户余额)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ", return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                sResult = oDataSrc1.Get_AccountBalance(id);
                oLog.writeLine("取得帐户余额", "", fromIP, "Get_AccountBalance(取得帐户余额)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ", USRIP:" + usrip);
                if (sResult == 0.921)
                {
                    mc.sMsg_Value = "查无此会员ID余额";
                    sResult = 0;
                }
                mc.sResult_Value = "0";
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得帐户余额", "", fromIP, "Get_AccountBalance(取得帐户余额)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Account_Balance"" : """ + sResult.ToString() + @""",";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("取得帐户余额", "", fromIP, "Get_AccountBalance(取得帐户余额)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ", return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        #endregion


        #region  充值

        [WebMethod(Description = "购买储值方案-送支付宝前(即时到账)")]
        public String Direct_pay_before(string ID, string CREDIT_PACK_ID, double AMOUNT_PAID, string PAYMENT_TYPE_ID, string logintype, string sToken, string USRIP)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            String Env = System.Configuration.ConfigurationSettings.AppSettings["Environment"];
            bool check_Env = false;
            
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                oLog.writeLine("购买储值方案-送支付宝前(即时到账)", "", fromIP, "Payment(购买储值方案-送支付宝前(即时到账))", APUtil.clsLog.enumMsgType.General, "ID:" + ID + ",LOGINTYPE:" + logintype + ",sToken:" + sToken);
                bResult = oDataSrc1.Check_Token(ID, logintype, sToken);

                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("购买储值方案-送支付宝前(即时到账)", "", fromIP, "Payment(购买储值方案-送支付宝前(即时到账))", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("购买储值方案-送支付宝前(即时到账)", "", fromIP, "Payment(购买储值方案-送支付宝前(即时到账))", APUtil.clsLog.enumMsgType.General, "ID:" + ID +
                   ",CREDIT_PACK_ID:" + CREDIT_PACK_ID + ",AMOUNT_PAID:" + AMOUNT_PAID + ",PAYMENT_TYPE_ID:" + PAYMENT_TYPE_ID +
                    ",USRIP:" + USRIP);
                mc.sResult_Value = oDataSrc1.Pre_Payment(ID, CREDIT_PACK_ID, AMOUNT_PAID, PAYMENT_TYPE_ID);
                if (Env == "TEST")
                {
                    if (mc.sResult_Value.IndexOf("DEP") != -1)
                        check_Env = true;
                    else
                        check_Env = false;
                }
                else
                {
                    if (mc.sResult_Value.IndexOf("DEPO") != -1)
                        check_Env = true;
                    else
                        check_Env = false;
                }
                if (check_Env)
                {
                    mc.sMsg_Value = mc.sResult_Value;
                    mc.sResult_Value = "0";
                    oLog.writeLine("购买储值方案-送支付宝前(即时到账)", "", fromIP, "Payment(购买储值方案-送支付宝前(即时到账))", APUtil.clsLog.enumMsgType.General, "取得訂單編號:" + mc.sMsg_Value);
                    
                    oDataSrc1.Commit();
                }
                else
                {
                    oLog.writeLine("购买储值方案-送支付宝前(即时到账)", "", fromIP, "Payment(购买储值方案-送支付宝前(即时到账))", APUtil.clsLog.enumMsgType.General, "取得訂單編號失敗:" + mc.sMsg_Value);
                    oDataSrc1.RollBack();
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("购买储值方案-送支付宝前(即时到账)", "", fromIP, "Payment(购买储值方案-送支付宝前(即时到账))", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("购买储值方案-送支付宝前(即时到账)", "", fromIP, "Payment(购买储值方案-送支付宝前(即时到账))", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        [WebMethod(Description = "购买储值方案-接支付宝回传(即时到账)")]
        public String Direct_pay_after(string ID, double AMOUNT_PAID, string orderid, string TXN_NO, string TXN_MSG, string logintype, string sToken, string USRIP)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            
            String sSubject = string.Empty;
            String sMailBody = string.Empty;
            String sResult = string.Empty;
            String sSMSBody = string.Empty;
            String sMsg = string.Empty;
            
            try
            {
                oDataSrc = new APUtil.clsDataSrc();
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                oLog.writeLine("购买储值方案-接支付宝回传(即时到账)", "", fromIP, "Payment(购买储值方案-接支付宝回传(即时到账))", APUtil.clsLog.enumMsgType.General, "ID:" + ID + ",LOGINTYPE:" + logintype + ",sToken:" + sToken);
                int verifytype = int.Parse(oDataSrc.GETVERIFYTYPE(ID));
                String verifyvalue = oDataSrc.GETVERIFYVALUE(ID, verifytype.ToString());
                double accountbanalance = oDataSrc1.Get_AccountBalance(ID);
                String sCName = oDataSrc.GETCNAME(ID);
                bResult = oDataSrc1.Check_Token(ID, logintype, sToken);

                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("购买储值方案-接支付宝回传(即时到账)", "", fromIP, "Payment(购买储值方案-接支付宝回传(即时到账))", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("购买储值方案-接支付宝回传(即时到账)", "", fromIP, "Payment(购买储值方案-接支付宝回传(即时到账))", APUtil.clsLog.enumMsgType.General, "AMOUNT_PAID:" + AMOUNT_PAID + ",ORDERID:" + orderid + ",TXN_NO:" + TXN_NO + ",TXN_MSG:" + TXN_MSG);
                mc.sResult_Value = oDataSrc1.Direct_pay(ID, AMOUNT_PAID, orderid, TXN_NO, TXN_MSG, logintype, sToken, USRIP);
                if (mc.sResult_Value != "0")
                    oDataSrc1.RollBack();
                else
                {
                    if (verifytype == 0)
                    {
                        //EMAIL传送迷你储存购买储值方案通知信
                        sSubject = "迷你储存购买储值方案通知信";
                        sMailBody = "亲爱的" + sCName + "先生/女士：";
                        sMailBody = sMailBody + "</br><p>您充值已成功，您的账户余额是" + accountbanalance + "元。若有疑问请";
                        sMailBody = sMailBody + "向微信客服提交您的问题，或致电400-886-8866，我们将即时为您服务。</p>";
                        sMailBody = sMailBody + "<p><a href='http://weixin.qq.com/r/TnVIUFfEggr9rRMz9yBc'><img src='http://60.248.34.96:8080/web/images/QRcode-mail-105px-wechat.png' alt='关注迷你储存' height='105' width='105'></a></p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        sMailBody = sMailBody + "</br></br>这是一封系统自动发送的邮件，请勿回复。";
                        sMailBody = sMailBody + "</br></br>";
                        sMailBody = sMailBody + "<p>迷你储存</p>";
                        sMailBody = sMailBody + "</br>";
                        sMailBody = sMailBody + "<p>"+DateTime.Now.ToString("yyyy-MM-dd")+"</p>";
                        sResult = oSend.sendMail(verifyvalue, "", sMailBody, sSubject);
                        //oLog.writeLine("购买储值方案-接支付宝回传(即时到账)", "", fromIP, "购买储值方案-接支付宝回传(即时到账)", APUtil.clsLog.enumMsgType.General, "sNewPwd:" + sNewPwd + ",sMailBody:" + sMailBody + ",sSubject:" + sSubject);
                        if (sResult != "0") throw new Exception(sResult);
                    }
                    else
                    {
                        //SMS傳送新密碼
                        //"尊敬的用户：您正在找回登录密码，校验码【变量】     ，切勿泄露，请前往http://www.minichucun.com 完成密码找回。"
                        sSMSBody = "尊敬的用户：您充值成功，您的账户余额是" + accountbanalance + "元，若有疑问请向微信客服提交您的问题，或致电400-886-8866，我们将即时为您服务。";
                        oLog.writeLine("购买储值方案-接支付宝回传(即时到账)", "", fromIP, "购买储值方案-接支付宝回传(即时到账)", APUtil.clsLog.enumMsgType.General, "ID:" + ID + ",sSMSBody:" + sSMSBody );

                        //待傳送簡訊寫入資料庫
                        sResult = oDataSrc1.add_sms(verifyvalue, sSMSBody);
                        if (sResult != "0")
                        {
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫失敗: " + sResult);
                        }
                        else
                        {
                            oLog.writeLine("会员激活", "", fromIP, "Active_Member(会员激活)", APUtil.clsLog.enumMsgType.General, "待傳送簡訊寫入資料庫成功 ");
                        }

                        sResult = oSend.SendSMS(sSMSBody, verifyvalue);  //发送SMS会员激活验证码
                        if (sResult == "code:2,msg:提交成功")
                        { sResult = "0"; }
                        else
                        {
                            String[] strSplit = sResult.Split(',');
                            if (strSplit.Length > 0)
                            {
                                sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                                sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                            }
                            oDataSrc.Rollback();
                            sJson_Tmp = " {";
                            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                            sJson_Tmp = sJson_Tmp + "}";
                            oLog.writeLine("购买储值方案-接支付宝回传(即时到账)", "", fromIP, "购买储值方案-接支付宝回传(即时到账)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                            return sJson_Tmp;
                        }
                    }
                    oDataSrc1.Commit();
                }
                    
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("购买储值方案-接支付宝回传(即时到账)", "", fromIP, "Payment(购买储值方案-接支付宝回传(即时到账))", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("购买储值方案-接支付宝回传(即时到账)", "", fromIP, "Payment(购买储值方案-接支付宝回传(即时到账))", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 购买储值方案
        /// </summary>
        /// <param name="ID">会员ID</param>
        /// <param name="CREDIT_PACK_ID">储值方案ID</param>
        /// <param name="AMOUNT_PAID">方案金额</param>
        /// <param name="PAYMENT_TYPE_ID">付款方式ID</param>
        /// <param name="TXN_NO">Transaction ID (eg. Credit card auth code, alipay txn code, etc)</param>
        /// <param name="CONFIRM_FLAG">储值确认注记</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="USRIP">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "购买储值方案")]
        public String Payment(string ID, string CREDIT_PACK_ID, double AMOUNT_PAID, string PAYMENT_TYPE_ID, string TXN_NO, string CONFIRM_FLAG, string logintype, string sToken, string USRIP)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                oLog.writeLine("购买储值方案", "", fromIP, "Payment(购买储值方案)", APUtil.clsLog.enumMsgType.General, "ID:" + ID +",LOGINTYPE:"+logintype+",sToken:"+sToken);
                bResult = oDataSrc1.Check_Token(ID, logintype, sToken);
                
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("购买储值方案", "", fromIP, "Payment(购买储值方案)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                mc.sResult_Value = oDataSrc1.Payment(ID, CREDIT_PACK_ID, AMOUNT_PAID, PAYMENT_TYPE_ID, TXN_NO, CONFIRM_FLAG);
                oLog.writeLine("购买储值方案", "", fromIP, "Payment(购买储值方案)", APUtil.clsLog.enumMsgType.General, "ID:" + ID +
                    ",CREDIT_PACK_ID:" + CREDIT_PACK_ID + ",AMOUNT_PAID:" + AMOUNT_PAID + ",PAYMENT_TYPE_ID:" + PAYMENT_TYPE_ID +
                     ",TXN_NO:" + TXN_NO + ",CONFIRM_FLAG:" + CONFIRM_FLAG + ",USRIP:" + USRIP);
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("购买储值方案", "", fromIP, "Payment(购买储值方案)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("购买储值方案", "", fromIP, "Payment(购买储值方案)", APUtil.clsLog.enumMsgType.General,"return:"+ sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 取得商品资料
        /// </summary>
        /// <param name="type">商品类别(例如:押金,租金,商品或ALL)</param>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得商品资料")]
        public String Get_Product(string type, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oLog.writeLine("取得商品资料", "", fromIP, "Get_Product(取得商品资料)", APUtil.clsLog.enumMsgType.General, "TYPE:"+ type +",ID:" + id + ",LOGINTYPE:" + logintype + ",sToken:" + sToken);  
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得商品资料", "", fromIP, "Get_Product(取得商品资料)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("取得商品资料", "", fromIP, "Get_Product(取得商品资料)", APUtil.clsLog.enumMsgType.General, "TYPE:" + type + ",USRIP: " + usrip);
                dt = oDataSrc1.Get_Product(type);
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "PRODUCT";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得商品资料", "", fromIP, "Get_Product(取得商品资料)", APUtil.clsLog.enumMsgType.General, "TYPE:" + type + ",回傳值:" + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "PRODUCT";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得商品资料", "", fromIP, "Get_Product(取得商品资料)", APUtil.clsLog.enumMsgType.General, "TYPE:" + type + ",回傳值:" + mc.sResult_Value);
                }
                return mc.sResult_Value;
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得商品资料", "", fromIP, "Get_Product(取得商品资料)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 取得储值方案
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得储值方案")]
        public String Get_Creditpacks(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得储值方案", "", fromIP, "Get_Creditpacks(取得储值方案)", APUtil.clsLog.enumMsgType.General, "ID:" + id +",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得储值方案", "", fromIP, "Get_Creditpacks(取得储值方案)", APUtil.clsLog.enumMsgType.General,"return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("取得储值方案", "", fromIP, "Get_Creditpacks(取得储值方案)", APUtil.clsLog.enumMsgType.General, "USRIP: " + usrip);
                dt = oDataSrc1.Get_Creditpacks();
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "CREDIT_PACKS";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得储值方案", "", fromIP, "Get_Creditpacks(取得储值方案)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "CREDIT_PACKS";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得储值方案", "", fromIP, "Get_Creditpacks(取得储值方案)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                return mc.sResult_Value;
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得储值方案", "", fromIP, "Get_Creditpacks(取得储值方案)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 取得付款方式
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得付款方式")]
        public String Get_Paymenttype(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得付款方式", "", fromIP, "Get_Paymenttype(取得付款方式)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得付款方式", "", fromIP, "Get_Paymenttype(取得付款方式)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("取得付款方式", "", fromIP, "Get_Paymenttype(取得付款方式)", APUtil.clsLog.enumMsgType.General, "USRIP: " + usrip);
                dt = oDataSrc1.Get_Paymenttype();
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "PAYMET_TYPE";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得付款方式", "", fromIP, "Get_Paymenttype(取得付款方式)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "PAYMET_TYPE";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得付款方式", "", fromIP, "Get_Paymenttype(取得付款方式)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                return mc.sResult_Value;
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得付款方式", "", fromIP, "Get_Paymenttype(取得付款方式)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }
        #endregion

        #region 我的储存

        /// <summary>
        /// 取得待出仓箱号清单
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得待出仓箱号清单")]
        public String Get_Atwarehouse_Box_list(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得待出仓箱号清单", "", fromIP, "Get_Atwarehousr_Box_list(取得待出仓箱号清单)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得待出仓箱号清单", "", fromIP, "Get_Atwarehousr_Box_list(取得待出仓箱号清单)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Atwarehouse_Boxlist(id);
                oLog.writeLine("取得待出仓箱号清单", "", fromIP, "Get_Atwarehousr_Box_list(取得待出仓箱号清单)", APUtil.clsLog.enumMsgType.General, "ID:" + id);
                if (dt.Rows.Count > 0)
                {
                    dt.TableName = "BOXES";
                    ds.Tables.Add(dt.Copy());
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得待出仓箱号清单", "", fromIP, "Get_Atwarehousr_Box_list(取得待出仓箱号清单)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "BOXES";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得待出仓箱号清单", "", fromIP, "Get_Atwarehousr_Box_list(取得待出仓箱号清单)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得待出仓箱号清单", "", fromIP, "Get_Atwarehousr_Box_list(取得待出仓箱号清单)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 取得待出仓箱号清单(By关键字搜寻)
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="keyword">关键字</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得待出仓箱号清单(By关键字搜寻)")]
        public String Get_Atwarehousr_Box_list_SearchByKeyword(string id, string logintype, string sToken, string keyword, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得待出仓箱号清单(By关键字搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByKeyword(取得待出仓箱号清单(By关键字搜寻))", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",LOGINTYPE:"+logintype +",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得待出仓箱号清单(By关键字搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByKeyword(取得待出仓箱号清单(By关键字搜寻))", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Atwarehouse_Boxlist(id, keyword);
                oLog.writeLine("取得待出仓箱号清单(By关键字搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByKeyword(取得待出仓箱号清单(By关键字搜寻))", APUtil.clsLog.enumMsgType.General, "ID:" + id);
                if (dt.Rows.Count > 0)
                {
                    dt.TableName = "BOXES";
                    ds.Tables.Add(dt.Copy());
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得待出仓箱号清单(By关键字搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByKeyword(取得待出仓箱号清单(By关键字搜寻))", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "BOXES";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得待出仓箱号清单(By关键字搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByKeyword(取得待出仓箱号清单(By关键字搜寻))", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得待出仓箱号清单(By关键字搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByKeyword(取得待出仓箱号清单(By关键字搜寻))", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 取得待出仓箱号清单(By日期区间搜寻)
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="startdate">起始日期</param>
        /// <param name="enddate">結束日期</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得待出仓箱号清单(By日期区间搜寻)")]
        public String Get_Atwarehousr_Box_list_SearchByDate(string id, string logintype, string sToken, string startdate, string enddate, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得待出仓箱号清单(By日期区间搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByDate(取得待出仓箱号清单(By日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得待出仓箱号清单(By日期区间搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByDate(取得待出仓箱号清单(By日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Atwarehouse_Boxlist(id, startdate, enddate);
                oLog.writeLine("取得待出仓箱号清单(By日期区间搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByDate(取得待出仓箱号清单(By日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",StartDate:" + startdate + ",EndDate:" + enddate);
                if (dt.Rows.Count > 0)
                {
                    dt.TableName = "BOXES";
                    ds.Tables.Add(dt.Copy());
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得待出仓箱号清单(By日期区间搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByDate(取得待出仓箱号清单(By日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "BOXES";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得待出仓箱号清单(By日期区间搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByDate(取得待出仓箱号清单(By日期区间搜寻))", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得待出仓箱号清单(By日期区间搜寻)", "", fromIP, "Get_Atwarehousr_Box_listSearchByDate(取得待出仓箱号清单(By日期区间搜寻))", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 编辑订单
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="workorderid">订单编号</param>
        /// <param name="expect_date">希望送达日期</param>
        /// <param name="province">省</param>
        /// <param name="city">市</param>
        /// <param name="zipcode">邮递区号</param>
        /// <param name="addr">地址</param>
        /// <param name="telno">家用电话</param>
        /// <param name="mobileno">手机</param>
        /// <param name="isaddaddr">是否加入常用地址</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "编辑订单")]
        public String Set_Workorder(string id, string workorderid, string expect_date, string expect_date1, string province, string city, string zipcode,
            string addr, string telno, string mobileno, bool isaddaddr, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("编辑订单", "", fromIP, "Set_Workorder(编辑订单)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("编辑订单", "", fromIP, "Set_Workorder(编辑订单)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("编辑订单", "", fromIP, "Set_Workorder(编辑订单)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",WORKORDERID:" + workorderid +
                    ",EXPECT_DATE:" + expect_date +",EXPECT_DATE1:" + expect_date1+ ",PROVINCE:" + province + ",CITY:" + city + "ZIPCODE:" + zipcode + ",ADDR:" + addr +
                    ",TELNO:" + telno + ",MOBILENO: " + mobileno + ",是否加入常用地址:" + isaddaddr + ",USRIP: " + usrip);
                mc.sResult_Value = oDataSrc1.Set_Workorder(id, workorderid, expect_date, expect_date1, province, city, addr, zipcode, mobileno, telno, isaddaddr, usrip);
                if (mc.sResult_Value == "-3")
                {
                    mc.sMsg_Value = "找不到此订单编号";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("编辑订单", "", fromIP, "Set_Workorder(编辑订单)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("编辑订单", "", fromIP, "Set_Workorder(编辑订单)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("编辑订单", "", fromIP, "Set_Workorder(编辑订单)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 查看订单
        /// </summary>
        /// <param name="workorderid">订单编号</param>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "查看订单")]
        public String Get_Workorder(string workorderid, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("查看订单", "", fromIP, "Get_Workorder(查看订单)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype +",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("查看订单", "", fromIP, "Get_Workorder(查看订单)", APUtil.clsLog.enumMsgType.General,"return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("查看订单", "", fromIP, "Get_Workorder(查看订单)", APUtil.clsLog.enumMsgType.General, "WORKORDERID:" + workorderid + ",USRIP: " + usrip);
                dt = oDataSrc1.Get_Workorder(workorderid);
                if (dt.Rows.Count > 0)
                {
                    dt.TableName = "WORKORDER";
                    ds.Tables.Add(dt.Copy());
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("查看订单", "", fromIP, "Get_Workorder(查看订单)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "WORKORDER";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("查看订单", "", fromIP, "Get_Workorder(查看订单)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("查看订单", "", fromIP, "Get_Workorder(查看订单)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 申请入库/出库
        /// </summary>
        /// <param name="ordertype">订单类别(入库或出库)</param>
        /// <param name="sJson">
        //        {
        //  "_account_id": "18",
        //  "_source": "IN或OUT",
        //  "_expect_date1": "2014/08/09",
        //  "_expect_date2": "2014/08/08",
        //  "_mobileno": "0911222332",
        //  "_telno": "02232323322",
        //  "_province":"上海市",
        //  "_city":"杨浦区",
        //  "_addr": "邯郸路220号",
        //  "_zipcode": "12312",
        //  "_isaddaddr": true,
        //  "_body": [
        //    {
        //      "productname": "专用箱",
        //      "quantity": 1,
        //      "price": 20,
        //      "sub_total": 20,
        //      "note": ""
        //    },
        //    {
        //      "productname": "汽泡膜",
        //      "quantity": 1,
        //      "price": 12,
        //      "sub_total": 12,
        //      "note": ""
        //    }
        //  ]
        //}
        /// </param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "申请入库/出库")]
        public String Add_Workorder(string sJson, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            string[] exprie_date = null;
            string[] exprie_date1 = null;
            string sSubject = string.Empty;
            string sMailBody = string.Empty;
            string sResult = string.Empty;
            string sMsg = string.Empty;
            string verifytype = string.Empty;
            string verifyvalue = string.Empty;
            bool bResult = false;
            String statusid = "70"; //出仓申请
            String sJson_Tmp = string.Empty;
            String sOrderNum1 = string.Empty;
            workorder1_table head = new workorder1_table();
            IList<orderdetail_table> body = new List<orderdetail_table>();
            head = JsonConvert.DeserializeObject<workorder1_table>(sJson);
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc = new APUtil.clsDataSrc();
                exprie_date = head._expect_date1.Split('/');
                exprie_date1 = head._expect_date2.Split('/');
                bResult = oDataSrc1.Check_Token(head._account_id, logintype, sToken);
                oLog.writeLine("新增订单", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "ID:" + head._account_id + ",LOGINTYPE:" + logintype + ",sToken:" + sToken + ",sJson:" + sJson);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("新增订单", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                String BOX_Amount = string.Empty;
                oDataSrc1.BeginTrans();
                verifytype = oDataSrc1.Get_VerifyType(head._account_id);
                verifyvalue = oDataSrc.GETVERIFYVALUE(head._account_id, verifytype);
                if (head._source.Equals("IN"))
                {
                    oLog.writeLine("新增订单(送空箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "==========START==========");
                    sOrderNum1 = oDataSrc1.Get_SEQNO("新申請", "NEW");
                    mc.sResult_Value = oDataSrc1.Add_Workorder(head._account_id, sOrderNum1, head._source, head._expect_date1, head._expect_date2,
                        head._province, head._city, head._addr, head._zipcode, head._mobileno, head._telno, head._isaddaddr, head._body[0].quantity, usrip);
                    oLog.writeLine("新增订单(送空箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "ACCOUNTID:" + head._account_id +
                        ",WORKORDERID:" + sOrderNum1 + ",WORKORDERTYPE:" + head._source + ",EXPECT_DATE1" + head._expect_date1 + ",EXPECT_DATE2" + head._expect_date2
                        + ",PROVINCE:" + head._province + ",CITY:" + head._city + ",ADDR:" + head._addr + ",ZIPCODE:" + head._zipcode
                        + ",MOBILE_NO:" + head._mobileno + ",TEL_NO:" + head._telno + ",ISADDADDR:" + head._isaddaddr);
                    //String sOrderNum2 = oDataSrc1.Get_SEQNO("入库", "REQ");
                    //mc.sResult_Value = oDataSrc1.Add_Workorder(head._account_id, sOrderNum2, "入库", head._source, head._expect_date2,
                    //    head._province, head._city, head._addr, head._zipcode, head._mobileno, head._telno, head._isaddaddr, head._body[0].quantity, usrip);
                    //oLog.writeLine("新增订单(入库待取箱)", "", usrip, "Add_Workorder", APUtil.clsLog.enumMsgType.General, "ACCOUNTID:" + head._account_id +
                    //    ",WORKORDERID:" + sOrderNum2 + ",WORKORDERTYPE:" + head._source + ",EXPECT_DATE2" + head._expect_date2
                    //    + ",PROVINCE:" + head._province + ",CITY:" + head._city + ",ADDR:" + head._addr + ",ZIPCODE:" + head._zipcode
                    //    + ",MOBILE_NO:" + head._mobileno + ",TEL_NO:" + head._telno + ",ISADDADDR:" + head._isaddaddr);

                    for (int i = 0; i <= head._body.Count - 1; i++)
                    {
                        mc.sResult_Value = oDataSrc1.Add_Orderdetail(sOrderNum1, head._body[i].productname, head._body[i].quantity,
                            head._body[i].price, head._body[i].sub_total, head._body[i].note);
                        oLog.writeLine("新增订单內容", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "Add_Orderdetail = >WORKORDERID:" + sOrderNum1 + ",PRODUCT_NAME:" + head._body[i].productname +
                            ",QTY:" + head._body[i].quantity + ",PRICE:" + head._body[i].price + ",SUB_TOTLA:" + head._body[i].sub_total +
                            ",NOTE:" + head._body[i].note);
                    }
                    if (verifytype == "0")
                    {
                        //傳送EMAIL
                        sSubject = "迷你儲存-入仓訂單成立";
                        sMailBody = "亲爱的"+ oDataSrc.GETCNAME(head._account_id) +"先生/女士： ";
                        sMailBody = sMailBody + "</br><p>感谢您使用迷你储存服务";
                        sMailBody = sMailBody + "</br>入仓订单号：" + sOrderNum1;
                        sMailBody = sMailBody + "</br>我们将会在"+exprie_date[0]+"年"+exprie_date[1]+"月"+exprie_date[2]+"日	至府上:";
                        sMailBody = sMailBody + "</br>" + head._province + head._city + head._addr + " 送达您申请的箱子";
                        sMailBody = sMailBody + "</br>"+exprie_date1[0] +"年"+exprie_date1[1]+"月"+exprie_date1[2]+"日 前往";
                        sMailBody = sMailBody + "</br>" + head._province + head._city + head._addr + "收箱子入仓。";
                        sMailBody = sMailBody + "</br></br>请点击以下链接，查看訂單狀態：http://www.minichucun.com </p>";
                        sMailBody = sMailBody + "</br><p></br>";
                        sMailBody = sMailBody + "</br>点击或是扫一下我们的二维码即可下载我们的APP哦。</p>";
                        sMailBody = sMailBody + "</br></br>";
                        sMailBody = sMailBody + "</br><p><a href='http://weixin.qq.com/r/TnVIUFfEggr9rRMz9yBc'><img src='http://60.248.34.96:8080/web/images/QRcode-mail-105px-wechat.png' alt='关注迷你储存' height='105' width='105'></a>";
                        sMailBody = sMailBody + "&nbsp;&nbsp;<a href='https://itunes.apple.com/us/app/mi-ni-chu-cun/id928994971?l=zh&ls=1&mt=8'><img src='http://60.248.34.96:8080/web/images/QRcode-mail-105px-apple.png' alt='迷你储存APP' height='105' width='105'></a></p></br>";
                        sMailBody = sMailBody + "</br>";
                        sMailBody = sMailBody + "</br><p>如果您在使用过程中遇到任何问题，您可以发邮件给我们：";
                        sMailBody = sMailBody + "service@minichucun.com";
                        sMailBody = sMailBody + "或者拨打我们的服务专线：400-886-8866与我们联系，我们会尽快为您解决。</p>";
                        sMailBody = sMailBody + "</br><p>这是一封系统自动发送的邮件，请勿回复。</p>";
                        sMailBody = sMailBody + "</br></br></br><p>迷你储存</p>";
                        sMailBody = sMailBody + "</br></br><p>" + DateTime.Now.ToString("yyyy-MM-dd") + "</p>";
                        sResult = oSend.sendMail(verifyvalue, "", sMailBody, sSubject); //发送电​​邮
                        oLog.writeLine("新增订单(送空箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "sSubject:" + sSubject + ",sMailBody:" + sMailBody );
                        if (sResult != "0")
                        {
                            oDataSrc.Rollback();
                            sJson_Tmp = " {";
                            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + "-1" + @""",";
                            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sResult + @""" ";
                            sJson_Tmp = sJson_Tmp + "}";
                            oLog.writeLine("新增订单(送空箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                            return sJson_Tmp;
                        }

                    }
                    else
                    {
                        //傳送SMS
                        string sSMS_Body = "感谢您使用迷你储存服务。";
                        sSMS_Body = sSMS_Body + "我们将会在" + exprie_date[0] + "年" + exprie_date[1] + "月" + exprie_date[2] + "日至府上:";
                        sSMS_Body = sSMS_Body + head._province + head._city + head._addr + "送达您申请的箱子。";
                        sSMS_Body = sSMS_Body + exprie_date1[0] + "年" + exprie_date1[1] + "月" + exprie_date1[2] + "日前往";
                        sSMS_Body = sSMS_Body + head._province + head._city + head._addr + "收箱子入仓。";
                        sResult = oSend.SendSMS(sSMS_Body, verifyvalue);
                        if (sResult == "code:2,msg:提交成功")
                        { sResult = "0"; }
                        else
                        {
                            String[] strSplit = sResult.Split(',');
                            if (strSplit.Length > 0)
                            {
                                sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                                sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                            }
                            oDataSrc.Rollback();
                            sJson_Tmp = " {";
                            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                            sJson_Tmp = sJson_Tmp + "}";
                            oLog.writeLine("新增订单(送空箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                            return sJson_Tmp;
                        }
                    }
                    oLog.writeLine("新增订单(送空箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "==========END==========");
                }
                else
                {
                    oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "==========START==========");
                    sOrderNum1 = oDataSrc1.Get_SEQNO("出库", "PICK");
                    String sTemp = string.Empty;
                    mc.sResult_Value = oDataSrc1.Add_Workorder(head._account_id, sOrderNum1, head._source, head._expect_date1, head._expect_date2,
                        head._province, head._city, head._addr, head._zipcode, head._mobileno, head._telno, head._isaddaddr, head._body[0].quantity, usrip);
                    oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "ACCOUNTID:" + head._account_id +
                        ",WORKORDERID:" + sOrderNum1 + ",WORKORDERTYPE:" + head._source + ",EXPECT_DATE1" + head._expect_date1
                        + ",PROVINCE:" + head._province + ",CITY:" + head._city + ",ADDR:" + head._addr + ",ZIPCODE:" + head._zipcode
                        + ",MOBILE_NO:" + head._mobileno + ",TEL_NO:" + head._telno + ",ISADDADDR:" + head._isaddaddr);
                    //2014/08/15 與耀民討論後,決定這裡不寫入ORDER_DETAIL
                    //for (int i = 0; i <= head._body.Count - 1; i++)
                    //{
                    //    if(head._body[i].productname.Equals("專用箱")){sTemp = head._body[i].note;}
                    //    mc.sResult_Value = oDataSrc1.Add_Orderdetail(sOrderNum1, head._body[i].productname, head._body[i].quantity,
                    //        head._body[i].price, head._body[i].sub_total, head._body[i].note);
                    //    oLog.writeLine("新增订单內容", "", usrip, "Add_Orderdetail", APUtil.clsLog.enumMsgType.General, "WORKORDERID:" + sOrderNum1 + ",PRODUCT_NAME:" + head._body[i].productname +
                    //        ",QTY:" + head._body[i].quantity + ",PRICE:" + head._body[i].price + ",SUB_TOTLA:" + head._body[i].sub_total +
                    //        ",NOTE:" + head._body[i].note);
                    //}
                    for (int i = 0; i <= head._body.Count - 1; i++)
                    {
                        //if (head._body[i].productname.Equals("專用箱")) { sTemp = head._body[i].note; }
                        if (head._body[i].productname.Trim().Equals("专用箱租金")) 
                        { 
                            sTemp = head._body[i].note + "," + sTemp;
                            oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "CALL Add_Workorderbox,Param => head._body[i].note:[" + head._body[i].note+"]");
                        }
                        
                    }
                    oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "CALL Add_Workorderbox,Param => orderid:" + sOrderNum1 + ",boxno:" + sTemp);
                    mc.sResult_Value = oDataSrc1.Add_Workorderbox(sOrderNum1, sTemp);
                    if (mc.sResult_Value != "0")
                        oDataSrc1.RollBack();
                    oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "CALL Update_Boxes,Param => orderid:" + sOrderNum1 + ",boxno:" + sTemp + ",statusid:" + statusid);
                    mc.sResult_Value = oDataSrc1.Update_Boxes(sTemp, statusid, sOrderNum1);
                    if (mc.sResult_Value != "0")
                        oDataSrc1.RollBack();

                    if (verifytype == "0")
                    {
                        //傳送EMAIL
                        sSubject = "迷你儲存-出仓訂單成立";
                        sMailBody = "亲爱的" + oDataSrc.GETCNAME(head._account_id) + "先生/女士： ";
                        sMailBody = sMailBody + "</br><p>感谢您使用迷你储存服务";
                        sMailBody = sMailBody + "</br>出仓订单号：" + sOrderNum1;
                        sMailBody = sMailBody + "</br>我们将会在" + exprie_date1[0] + "年" + exprie_date1[1] + "月" + exprie_date1[2] + "日	至府上:";
                        sMailBody = sMailBody + "</br>" + head._province + head._city + head._addr + " 送达您的箱子";
                        sMailBody = sMailBody + "</br></br>请点击以下链接，查看訂單狀態：http://www.minichucun.com </p>";
                        sMailBody = sMailBody + "</br><p></br>";
                        sMailBody = sMailBody + "</br>点击或是扫一下我们的二维码即可下载我们的APP哦。</p>";
                        sMailBody = sMailBody + "</br></br>";
                        sMailBody = sMailBody + "</br><p><a href='http://weixin.qq.com/r/TnVIUFfEggr9rRMz9yBc'><img src='http://60.248.34.96:8080/web/images/QRcode-mail-105px-wechat.png' alt='关注迷你储存' height='105' width='105'></a>";
                        sMailBody = sMailBody + "&nbsp;&nbsp;<a href='https://itunes.apple.com/us/app/mi-ni-chu-cun/id928994971?l=zh&ls=1&mt=8'><img src='http://60.248.34.96:8080/web/images/QRcode-mail-105px-apple.png' alt='迷你储存APP' height='105' width='105'></a></p></br>";
                        sMailBody = sMailBody + "</br>";
                        sMailBody = sMailBody + "</br><p>如果您在使用过程中遇到任何问题，您可以发邮件给我们：";
                        sMailBody = sMailBody + "service@minichucun.com";
                        sMailBody = sMailBody + "或者拨打我们的服务专线：400-886-8866与我们联系，我们会尽快为您解决。</p>";
                        sMailBody = sMailBody + "</br><p>这是一封系统自动发送的邮件，请勿回复。</p>";
                        sMailBody = sMailBody + "</br></br></br><p>迷你储存</p>";
                        sMailBody = sMailBody + "</br></br><p>" + DateTime.Now.ToString("yyyy-MM-dd") + "</p>";
                        sResult = oSend.sendMail(verifyvalue, "", sMailBody, sSubject); //发送电​​邮
                        oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "sSubject:" + sSubject + ",sMailBody:" + sMailBody);
                        if (sResult != "0")
                        {
                            oDataSrc.Rollback();
                            sJson_Tmp = " {";
                            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + "-1" + @""",";
                            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sResult + @""" ";
                            sJson_Tmp = sJson_Tmp + "}";
                            oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                            return sJson_Tmp;
                        }

                    }
                    else
                    {
                        //傳送SMS
                        string sSMS_Body = "感谢您使用迷你储存服务，";
                        sSMS_Body = sSMS_Body + "我们将会在" + exprie_date1[0] + "年" + exprie_date1[1] + "月" + exprie_date1[2] + "日。至府上:";
                        sSMS_Body = sSMS_Body + head._province + head._city + head._addr + "送达您的箱子。";
                        sResult = oSend.SendSMS(sSMS_Body, verifyvalue);
                        if (sResult == "code:2,msg:提交成功")
                        { sResult = "0"; }
                        else
                        {
                            String[] strSplit = sResult.Split(',');
                            if (strSplit.Length > 0)
                            {
                                sResult = strSplit[0].Substring(5, strSplit[0].Length - 5);
                                sMsg = strSplit[1].Substring(4, strSplit[1].Length - 4);
                            }
                            oDataSrc.Rollback();
                            sJson_Tmp = " {";
                            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + sResult + @""",";
                            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sMsg + @""" ";
                            sJson_Tmp = sJson_Tmp + "}";
                            oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                            return sJson_Tmp;
                        }
                    }


                    oLog.writeLine("新增订单(出库待送箱)", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "==========END==========");
                }

                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("新增订单", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }

            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Order_No"" : """ + sOrderNum1 + @""",";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("新增订单", "", fromIP, "Add_Workorder(新增订单)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
            return sJson_Tmp;
        }

        [WebMethod(Description = "取消出库订单")]
        public String Cancel_OutWorkorder(string id, string logintype, string sToken, string workorderid, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String statusid = "97";
            String sJson_Tmp = string.Empty;
            DataTable dt = new DataTable();
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取消出库订单", "", fromIP, "Cancel_OutWorkorder(取消出库订单)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取消出库订单", "", fromIP, "Cancel_OutWorkorder(取消出库订单)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                oLog.writeLine("取消出库订单", "", fromIP, "Cancel_OutWorkorder(取消出库订单)", APUtil.clsLog.enumMsgType.General, "WORKORDERID:" + workorderid + "STATUSID" + statusid);
                mc.sResult_Value = oDataSrc1.Update_Workorder(workorderid, statusid);
                dt = oDataSrc1.Get_Workorderbox(workorderid);
                foreach (DataRow dr in dt.Rows)
                {
                    oDataSrc1.Update_Boxes(dr["BOX_ID"].ToString(), statusid, workorderid);
                }
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取消出库订单", "", fromIP, "Cancel_OutWorkorder(取消出库订单)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("取消出库订单", "", fromIP, "Cancel_OutWorkorder(取消出库订单)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }


        [WebMethod(Description = "订单管理")]
        public String Get_Workorder_V2(string id, string logintype, string sToken, string ordertype, string statusid, string startdate, string enddate, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("订单管理", "", fromIP, "Get_Workorder_V2(订单管理)", APUtil.clsLog.enumMsgType.General, "ID:" + id +",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("订单管理", "", fromIP, "Get_Workorder_V2(订单管理)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Workorder_BySearch(id, ordertype, statusid, startdate, enddate);
                oLog.writeLine("订单管理", "", fromIP, "Get_Workorder_V2(订单管理)", APUtil.clsLog.enumMsgType.General, "ID:" + id +
                    ",ORDERTYPE:" + ordertype + ",STARTDATE:" + startdate + ",ENDDATE:" + enddate);
                if (dt.Rows.Count > 0)
                {
                    dt.TableName = "WORKORDER";
                    ds.Tables.Add(dt.Copy());
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("订单管理", "", fromIP, "Get_Workorder_V2(订单管理)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "WORKORDER";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("订单管理", "", fromIP, "Get_Workorder_V2(订单管理)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }

            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("订单管理", "", fromIP, "Get_Workorder_V2(订单管理)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        /// <summary>
        /// 编辑物品
        /// </summary>
        /// <param name="sJson">
        //{
        //  "_boxno": "A12390",
        //  "_boxdesc": "descdskfalfja",
        //  "_body": [
        //    {
        //      "_item_image": "http://www.google.com",
        //      "_item_type": "type1",
        //      "_item_desc": "desc1"
        //    },
        //    {
        //      "_item_image": "http://www.google.com",
        //      "_itme_type": "type2",
        //      "_item_desc": "desc2"
        //    }
        //  ]
        //}
        /// </param>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        //[WebMethod(Description = "修改箱內资料")]
        public String Modify_Boxcontent(string sJson, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            boxes_table head = new boxes_table();
            IList<boxcontent_table> body = new List<boxcontent_table>();
            head = JsonConvert.DeserializeObject<boxes_table>(sJson);
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }
                oDataSrc1.BeginTrans();
                mc.sResult_Value = oDataSrc1.Clear_Boxcontent(head._boxno);
                oLog.writeLine("清除箱內资料", "", usrip, "Modify_Boxdesc", APUtil.clsLog.enumMsgType.General, "Clear_Boxcontent = >BOX_NO:" + head._boxno);
                mc.sResult_Value = oDataSrc1.Modify_Boxdesc(head._boxno, head._boxdesc);
                oLog.writeLine("修改箱子描述", "", usrip, "Modify_Boxdesc", APUtil.clsLog.enumMsgType.General, "BOX_NO:" + head._boxno + ",BOX_DESC:" + head._boxdesc);
                for (int i = 0; i <= head._body.Count - 1; i++)
                {
                    mc.sResult_Value = oDataSrc1.Add_Boxcontent(head._boxno, head._body[i]._item_type,
                        head._body[i]._item_desc, head._body[i]._item_image);
                    oLog.writeLine("修改箱內资料", "", usrip, "Modify_Boxdesc", APUtil.clsLog.enumMsgType.General, "Add_Boxcontent => BOX_NO:" + head._boxno + ",BOX_DESC:" + head._boxdesc +
                        ",ITEM_TYPE:" + head._body[i]._item_type + ",ITEM_DESC:" + head._body[i]._item_desc +
                        ",ITEM_IMAGE:" + head._body[i]._item_image);
                }
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("修改箱內资料", "", usrip, "Modify_Boxcontent", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            return sJson_Tmp;
        }

        [WebMethod(Description = "修改箱內资料")]
        public String Modify_Boxcontent_V2(string itemid,string itemtype,string itemdesc,string imageurl, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("修改箱內资料", "", fromIP, "Modify_Boxcontent_V2(修改箱內资料)", APUtil.clsLog.enumMsgType.General, "ID:" + id +",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("修改箱內资料", "", fromIP, "Modify_Boxcontent_V2(修改箱內资料)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                oDataSrc1.BeginTrans();
                oLog.writeLine("修改箱內资料", "", fromIP, "Modify_Boxcontent_V2(修改箱內资料)", APUtil.clsLog.enumMsgType.General, "ITEMID:"+itemid+",ITEMTYPE:"+itemtype+",ITEMDESC:"+itemdesc+",IMAGEURL:"+imageurl);
                mc.sResult_Value = oDataSrc1.Modify_BoxContentItem(itemid, itemtype, itemdesc, imageurl);
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("修改箱內资料", "", fromIP, "Modify_Boxcontent_V2(修改箱內资料)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("修改箱內资料", "", fromIP, "Modify_Boxcontent_V2(修改箱內资料)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        [WebMethod(Description = "修改箱子描述")]
        public String Modify_Boxdesc(string boxid, string boxdesc,string id,string logintype,string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oLog.writeLine("修改箱子描述", "", fromIP, "Modify_Boxdesc(修改箱子描述)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",LOGINTYPE:" + logintype + ",sToken:" + sToken + ",BOXID:" + boxid + ",BOXDESC:" + boxdesc);
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("修改箱子描述", "", fromIP, "Modify_Boxdesc(修改箱子描述)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                oDataSrc1.BeginTrans();
                oLog.writeLine("修改箱子描述", "", fromIP, "Modify_Boxdesc(修改箱子描述)", APUtil.clsLog.enumMsgType.General, "BOXID:" + boxid + ",BOXDESC:" + boxdesc);
                mc.sResult_Value = oDataSrc1.Modify_Boxdesc(boxid, boxdesc);
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("修改箱子描述", "", fromIP, "Modify_Boxdesc(修改箱子描述)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("修改箱子描述", "", fromIP, "Modify_Boxdesc(修改箱子描述)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 新增箱內资料
        /// </summary>
        /// <param name="boxid"></param>
        /// <param name="itemtype"></param>
        /// <param name="itemdesc"></param>
        /// <param name="imageurl"></param>
        /// <param name="boxdesc"></param>
        /// <param name="id"></param>
        /// <param name="logintype"></param>
        /// <param name="sToken"></param>
        /// <param name="usrip"></param>
        /// <returns></returns>
        [WebMethod(Description="新增箱內资料")] 
        public String Add_Boxcontent(string boxid,string itemtype,string itemdesc,string imageurl,string boxdesc, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oLog.writeLine("新增箱內资料", "", fromIP, "Add_Boxcontent(新增箱內资料)", APUtil.clsLog.enumMsgType.General, "ID:" + id + ",LOGINTYPE:" + logintype + ",sToken:" + sToken);
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("新增箱內资料", "", fromIP, "Add_Boxcontent(新增箱內资料)", APUtil.clsLog.enumMsgType.General, "return:"+sJson_Tmp);
                    return sJson_Tmp;
                }
                oDataSrc1.BeginTrans();
                oLog.writeLine("新增箱內资料", "", fromIP, "Add_Boxcontent(新增箱內资料)", APUtil.clsLog.enumMsgType.General, "BOXID:" + boxid + ",ITEMDESC:" + itemdesc + ",ITEMTYPE:" + itemtype + ",IMAGEURL:" + imageurl);
                mc.sResult_Value = oDataSrc1.Add_Boxcontent(boxid, itemtype, itemdesc, imageurl);
                if (mc.sResult_Value != "0") { oDataSrc1.RollBack(); return mc.sResult_Value; }
                oLog.writeLine("新增箱內资料", "", fromIP, "Add_Boxcontent(新增箱內资料)", APUtil.clsLog.enumMsgType.General, "BOXID:" + boxid + ",BOXDESC:" + boxdesc);
                mc.sResult_Value = oDataSrc1.Modify_Boxdesc(boxid, boxdesc);
                if (mc.sResult_Value != "0") { oDataSrc1.RollBack(); return mc.sResult_Value; }

                oDataSrc1.Commit();
            }catch(Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("新增箱內资料", "", fromIP, "Add_Boxcontent(新增箱內资料)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }finally
            {
                oDataSrc1 = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("新增箱內资料", "", fromIP, "Add_Boxcontent(新增箱內资料)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        /// <summary>
        /// 刪除箱內资料
        /// </summary>
        /// <param name="itemid"></param>
        /// <param name="id"></param>
        /// <param name="logintype"></param>
        /// <param name="sToken"></param>
        /// <param name="usrip"></param>
        /// <returns></returns>
        [WebMethod(Description="刪除箱內资料")]
        public String Clear_BoxcontentByItem(string itemid, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);

                oLog.writeLine("刪除箱內资料", "", fromIP, "Clear_BoxcontentByItem(刪除箱內资料)", APUtil.clsLog.enumMsgType.General, "ID:" + id+",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("刪除箱內资料", "", fromIP, "Clear_BoxcontentByItem(刪除箱內资料)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }
                oDataSrc1.BeginTrans();
                oLog.writeLine("刪除箱內资料", "", fromIP, "Clear_BoxcontentByItem(刪除箱內资料)", APUtil.clsLog.enumMsgType.General, "ITEMID:" + itemid );
                mc.sResult_Value = oDataSrc1.Clear_BoxcontentByItem(itemid);
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("刪除箱內资料", "", fromIP, "Clear_BoxcontentByItem(刪除箱內资料)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("刪除箱內资料", "", fromIP, "Clear_BoxcontentByItem(刪除箱內资料)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }


        /// <summary>
        /// 取得物品清单 Ver0.3 (含搜寻功能)
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="statusid">订单狀態</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="startdate">開始日期</param>
        /// <param name="enddate">結束日期</param>
        /// <param name="keyword">关键字</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        [WebMethod(Description = "取得物品清单 Ver0.3 (含搜寻功能)")]
        public String Get_Workorder_boxV3_BySearch(string id, string statusid, string logintype, string sToken,
           string startdate, string enddate, string keyword, string usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = string.Empty;
            bool bResult = false;
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                oLog.writeLine("取得物品清单 Ver0.3 (含搜寻功能)", "", fromIP, "Get_Workorderbox_V3_Search(取得物品清单 Ver0.3 (含搜寻功能))", APUtil.clsLog.enumMsgType.General, "ID:" + id +",LOGINTYPE:"+logintype+",sToken:"+sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得物品清单 Ver0.3 (含搜寻功能)", "", fromIP, "Get_Workorderbox_V3_Search(取得物品清单 Ver0.3 (含搜寻功能))", APUtil.clsLog.enumMsgType.General, "return:"+ sJson_Tmp);
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Workorderbox_V3_Search(id, statusid, startdate, enddate, keyword);
                if (dt.Rows.Count > 0) 
                {
                    ds.Tables.Add(dt.Copy());
                    oLog.writeLine("取得物品清单 Ver0.3 (含搜寻功能)", "", fromIP, "Get_Workorderbox_V3_Search(取得物品清单 Ver0.3 (含搜寻功能))", APUtil.clsLog.enumMsgType.General, JsonConvert.SerializeObject(ds));
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "Table1";
                    ds.Tables.Add(table);
                    oLog.writeLine("取得物品清单 Ver0.3 (含搜寻功能)", "", fromIP, "Get_Workorderbox_V3_Search(取得物品清单 Ver0.3 (含搜寻功能))", APUtil.clsLog.enumMsgType.General, JsonConvert.SerializeObject(ds));
                }
                oLog.writeLine("取得物品清单 Ver0.3 (含搜寻功能)", "", fromIP, "Get_Workorderbox_V3_Search(取得物品清单 Ver0.3 (含搜寻功能))", APUtil.clsLog.enumMsgType.General, "ID:" + id +
                    ",STATUSID:" + statusid + ",LOGINTYPE:" + logintype + " ,TOKEN:" + sToken + ",StartDate:" + startdate +
                    ",EndDate:" + enddate + ",KEYWORD:" + keyword + ",USRIP:" + usrip);
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得物品清单 Ver0.3 (含搜寻功能)", "", fromIP, "Get_Workorderbox_V3_Search(取得物品清单 Ver0.3 (含搜寻功能))", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return JsonConvert.SerializeObject(ds);
        }


        /// <summary>
        /// 取得物品清单(By关键字) Ver0.1
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="keyword">关键字</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        //[WebMethod(Description = "取得物品清单(By关键字) Ver0.1")]
        public String Get_Workorder_box_SearchByKeyword(string id, string keyword, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            DataTable dt = new DataTable();
            DataTable dt1 = new DataTable();
            ArrayList aryHead = new ArrayList();
            ArrayList aryBody = new ArrayList();
            workorder_table workorder = new workorder_table();
            workorder_box_table workorderbox = new workorder_box_table();
            String sDefault_IMAGEPATH = System.Configuration.ConfigurationSettings.AppSettings["DEFAULT_IMAGE_PATH"];
            oLog.writeLine("取得物品清单(By关键字) Ver0.1", "", usrip, "Get_Workorder_box_SearchByKeyword", APUtil.clsLog.enumMsgType.General, "ID: " + id + ",KEYWORD:" + keyword + ",USRIP: " + usrip);
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Workorderid(id);
                foreach (DataRow dr in dt.Rows)
                {
                    workorder = new workorder_table();
                    workorder._workorder_id = dr["WORKORDER_ID"].ToString();
                    workorder._update_time = dr["UPDATE_TIME"].ToString();
                    workorder._order_status = mc.sStatus_Name_Value(Convert.ToInt16(dr["ORDER_STATUS"].ToString()));
                    dt1 = oDataSrc1.Get_Workorderbox(dr["WORKORDER_ID"].ToString(), keyword);
                    aryBody = new ArrayList();
                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        workorderbox = new workorder_box_table();
                        workorderbox._box_id = dr1["BOX_ID"].ToString();
                        workorderbox._box_desc = dr1["BOX_DESC"].ToString();
                        if (dr1["BOX_FIRST_IMAGE"].ToString() == "" || dr1["BOX_FIRST_IMAGE"] == null)
                        { 
                            workorderbox._box_first_image = sDefault_IMAGEPATH;
                            oLog.writeLine("取得物品清单(By关键字) Ver0.1", "", usrip, "Get_Workorder_box_SearchByKeyword", APUtil.clsLog.enumMsgType.General, "BOXID:" + dr1["BOX_ID"].ToString() + ",BOX_DESC:" + dr1["BOX_DESC"].ToString() + ",BOX_FIRST_IMAGE" + sDefault_IMAGEPATH);
                        }
                        else { 
                            workorderbox._box_first_image = dr1["BOX_FIRST_IMAGE"].ToString();
                            oLog.writeLine("取得物品清单(By关键字) Ver0.1", "", usrip, "Get_Workorder_box_SearchByKeyword", APUtil.clsLog.enumMsgType.General, "BOXID:" + dr1["BOX_ID"].ToString() + ",BOX_DESC:" + dr1["BOX_DESC"].ToString() + ",BOX_FIRST_IMAGE" + dr1["BOX_FIRST_IMAGE"]);
                        }
                        aryBody.Add(workorderbox);
                    }
                    workorder.body = aryBody;
                    aryHead.Add(workorder);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得物品清单(By关键字) Ver0.1", "", usrip, "Get_Workorder_box_SearchByKeyword", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            oLog.writeLine("取得物品清单(By关键字) Ver0.1", "", usrip, "Get_Workorder_box_SearchByKeyword", APUtil.clsLog.enumMsgType.General, "Result:" + JsonConvert.SerializeObject(aryHead));
            return JsonConvert.SerializeObject(aryHead);
        }

        /// <summary>
        /// 取得物品清单(By日期區間)Ver0.1
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="startdate">起始日期</param>
        /// <param name="enddate">結束日期</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        //[WebMethod(Description = "取得物品清单(By日期區間) Ver0.1")]
        public String Get_Workorder_box_SearchByDate(string id, string startdate, string enddate, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            DataTable dt = new DataTable();
            DataTable dt1 = new DataTable();
            ArrayList aryHead = new ArrayList();
            ArrayList aryBody = new ArrayList();
            workorder_table workorder = new workorder_table();
            workorder_box_table workorderbox = new workorder_box_table();
            String sDefault_IMAGEPATH = System.Configuration.ConfigurationSettings.AppSettings["DEFAULT_IMAGE_PATH"];
            oLog.writeLine("取得物品清单(By日期搜尋) Ver0.1", "", usrip, "Get_Workorder_box_SearchByDate", APUtil.clsLog.enumMsgType.General, "ID: " + id + ",STARTDATE:" + startdate + ",ENDDATE: " + enddate + ",USRIP: " + usrip);
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Workorderid(id, startdate, enddate);
                foreach (DataRow dr in dt.Rows)
                {
                    workorder = new workorder_table();
                    workorder._workorder_id = dr["WORKORDER_ID"].ToString();
                    workorder._update_time = dr["UPDATE_TIME"].ToString();
                    workorder._order_status = mc.sStatus_Name_Value(Convert.ToInt16(dr["ORDER_STATUS"].ToString()));
                    dt1 = oDataSrc1.Get_Workorderbox(dr["WORKORDER_ID"].ToString());
                    aryBody = new ArrayList();
                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        workorderbox = new workorder_box_table();
                        workorderbox._box_id = dr1["BOX_ID"].ToString();
                        workorderbox._box_desc = dr1["BOX_DESC"].ToString();
                        if (dr1["BOX_FIRST_IMAGE"].ToString() == "" || dr1["BOX_FIRST_IMAGE"] == null)
                        { workorderbox._box_first_image = sDefault_IMAGEPATH; }
                        else { workorderbox._box_first_image = dr1["BOX_FIRST_IMAGE"].ToString(); }
                        aryBody.Add(workorderbox);
                    }
                    workorder.body = aryBody;
                    aryHead.Add(workorder);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得物品清单(By日期搜尋) Ver0.1", "", usrip, "Get_Workorder_box_SearchByDate", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            oLog.writeLine("取得物品清单(By日期搜尋) Ver0.1", "", usrip, "Get_Workorder_box_SearchByDate", APUtil.clsLog.enumMsgType.General, "Result:" + JsonConvert.SerializeObject(aryHead));
            return JsonConvert.SerializeObject(aryHead);
        }

        /// <summary>
        /// 取得物品清单 Ver0.2 (含搜尋功能)
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="statusid">订单狀態</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="startdate">開始日期</param>
        /// <param name="enddate">結束日期</param>
        /// <param name="keyword">关键字</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        //[WebMethod(Description = "取得物品清单 Ver0.2 (含搜尋功能)")]
        public String Get_Workorder_boxV2_BySearch(string id, string statusid, string logintype, string sToken,
            string startdate, string enddate, string keyword, string usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = string.Empty;
            bool bResult = false;
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Workorderbox_V2_Search(id, statusid, startdate, enddate, keyword);
                if (dt.Rows.Count > 0) { ds.Tables.Add(dt.Copy()); }
                oLog.writeLine("取得物品清单 Ver0.2 (含搜尋功能)", "", usrip, "Get_Workorderbox_V2_Search", APUtil.clsLog.enumMsgType.General, "ID:" + id +
                    ",STATUSID:" + statusid + ",LOGINTYPE:" + logintype + "TOKEN:" + sToken + ",StartDate:" + startdate +
                    ",EndDate:" + enddate + ",KEYWORD:" + keyword + ",USRIP:" + usrip);
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得物品清单 Ver0.2 (含搜尋功能)", "", usrip, "Get_Workorderbox_V2_Search", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            oLog.writeLine("取得物品清单 Ver0.2 (含搜尋功能)", "", usrip, "Get_Workorderbox_V2_Search", APUtil.clsLog.enumMsgType.General, "Result:" + JsonConvert.SerializeObject(ds));
            return JsonConvert.SerializeObject(ds);
        }


        /// <summary>
        /// 取得物品清单 Ver0.2
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        //[WebMethod(Description="取得物品清单 Ver0.2")]
        public String Get_Workorder_boxV2(string id, string statusid, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = string.Empty;
            bool bResult = false;
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Workorderbox_V2(id, statusid);
                if (dt.Rows.Count > 0) { ds.Tables.Add(dt.Copy()); }
                oLog.writeLine("取得物品清单 Ver0.2", "", usrip, "Get_Workorder_boxV2", APUtil.clsLog.enumMsgType.General, "ID:" + id +
                    ",STATUSID:" + statusid + ",LOGINTYPE:" + logintype + "TOKEN:" + sToken + ",USRIP:" + usrip);
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得物品清单 Ver0.2", "", usrip, "Get_Workorder_boxV2", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            oLog.writeLine("取得物品清单 Ver0.2", "", usrip, "Get_Workorder_boxV2", APUtil.clsLog.enumMsgType.General, "Result:" + JsonConvert.SerializeObject(ds));
            return JsonConvert.SerializeObject(ds);
        }

        /// <summary>
        /// 取得物品清单Ver0.1
        /// </summary>
        /// <param name="id">会员ID</param>
        /// <param name="logintype">登入类别(WEB或MOBILE)</param>
        /// <param name="sToken">TOKEN</param>
        /// <param name="usrip">IP位址</param>
        /// <returns></returns>
        //[WebMethod(Description = "取得物品清单 Ver0.1")]
        public String Get_Workorder_box(string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            DataTable dt = new DataTable();
            DataTable dt1 = new DataTable();
            ArrayList aryHead = new ArrayList();
            ArrayList aryBody = new ArrayList();
            workorder_table workorder = new workorder_table();
            workorder_box_table workorderbox = new workorder_box_table();
            String sDefault_IMAGEPATH = System.Configuration.ConfigurationSettings.AppSettings["DEFAULT_IMAGE_PATH"];
            oLog.writeLine("取得物品清单 Ver0.1", "", usrip, "Get_Workorder_box", APUtil.clsLog.enumMsgType.General, "ID: " + id + ",USRIP: " + usrip);
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }
                dt = oDataSrc1.Get_Workorderid(id);
                foreach (DataRow dr in dt.Rows)
                {
                    workorder = new workorder_table();
                    workorder._workorder_id = dr["WORKORDER_ID"].ToString();
                    workorder._update_time = dr["UPDATE_TIME"].ToString();
                    workorder._order_status = mc.sStatus_Name_Value(Convert.ToInt16(dr["ORDER_STATUS"].ToString()));
                    dt1 = oDataSrc1.Get_Workorderbox(dr["WORKORDER_ID"].ToString());
                    aryBody = new ArrayList();
                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        workorderbox = new workorder_box_table();
                        workorderbox._box_id = dr1["BOX_ID"].ToString();
                        workorderbox._box_desc = dr1["BOX_DESC"].ToString();
                        if (dr1["BOX_FIRST_IMAGE"].ToString() == "" || dr1["BOX_FIRST_IMAGE"] == null)
                        { workorderbox._box_first_image = sDefault_IMAGEPATH; }
                        else { workorderbox._box_first_image = dr1["BOX_FIRST_IMAGE"].ToString(); }
                        aryBody.Add(workorderbox);
                    }
                    workorder.body = aryBody;
                    aryHead.Add(workorder);
                }
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得物品清单 Ver0.1", "", usrip, "Get_Workorder_box", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            oLog.writeLine("取得物品清单 Ver0.1", "", usrip, "Get_Workorder_box", APUtil.clsLog.enumMsgType.General, "Result:" + JsonConvert.SerializeObject(aryHead));
            return JsonConvert.SerializeObject(aryHead);
        }

        [WebMethod(Description = "检查API Version")]
        public String Check_APIVersion(string sVersion, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            bool check_result = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            String version = System.Configuration.ConfigurationSettings.AppSettings["API_Version"];
            String temp = string.Empty;
            if (sVersion == "" ||  usrip == "")
            {
                SortedList<string, string> myString = new SortedList<string, string>();
                myString.Add("sVersion", sVersion);
                myString.Add("usrip", usrip);
                foreach (KeyValuePair<string, string> condition in myString)
                {
                    if(condition.Value == "")
                        temp = temp + condition.Key + "/";
                }
                
                mc.sResult_Value = "-9";
                mc.sMsg_Value = "缺少传入参数:" + temp;
                sJson_Tmp = " {";
                sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""",";
                sJson_Tmp = sJson_Tmp + @"""Server API Version"" : """ + version + @""" ";
                sJson_Tmp = sJson_Tmp + "}";
                oLog.writeLine("检查API Version", "", fromIP, "Check_APIVersion(检查API Version)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                return sJson_Tmp;
            }
            oLog.writeLine("检查API Version", "", fromIP, "Check_APIVersion(检查API Version)", APUtil.clsLog.enumMsgType.General,"sVersion:"+sVersion + ",USRIP: " + usrip);
            try
            {
                //sVersion Sample: v1.0
                if (sVersion.IndexOf("v") != -1)
                {
                    string pVersion = sVersion.Substring(1, 1);
                    string cVersion = version.Substring(1, 1);
                    if (int.Parse(pVersion) < int.Parse(cVersion))
                    {
                        check_result = true;
                        mc.sMsg_Value = "true";
                    }
                    else
                    {
                        check_result = false;
                        mc.sMsg_Value = "false";
                    }
                }
                else
                {
                    mc.sResult_Value = "-8";
                    mc.sMsg_Value = "传入参数[sVersion]格式错误";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Server API Version"" : """ + version + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("检查API Version", "", fromIP, "Check_APIVersion(检查API Version)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }

                mc.sResult_Value = "0";
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得API Version", "", fromIP, "Get_APIVersion(取得API Version)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Server API Version"" : """ + version + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            return sJson_Tmp;
        }

        #endregion


        #region  微信公眾平台

        [WebMethod(Description = "取得微信公众平台TOKEN")]
        public String Get_WxToken　(string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oLog.writeLine("取得微信公众平台TOKEN", "", fromIP, "Get_WxToken(取得微信公众平台TOKEN)", APUtil.clsLog.enumMsgType.General, "USRIP: " + usrip);
                dt = oDataSrc1.Get_WxToken();
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "WXTOKEN";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得微信公众平台TOKEN", "", fromIP, "Get_WxToken(取得微信公众平台TOKEN)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "CREDIT_PACKS";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得微信公众平台TOKEN", "", fromIP, "Get_WxToken(取得微信公众平台TOKEN)", APUtil.clsLog.enumMsgType.General, "Result: " + mc.sResult_Value);
                }
                return mc.sResult_Value;
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得微信公众平台TOKEN", "", fromIP, "Get_WxToken(取得微信公众平台TOKEN)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        [WebMethod(Description = "更新微信公众平台TOKEN")]
        public String Set_WxToken(String appid,String token,String addTimestamp,String usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                oLog.writeLine("更新微信公众平台TOKEN", "", fromIP, "Set_WxToken(更新微信公众平台TOKEN)", APUtil.clsLog.enumMsgType.General, "APPID:" + appid + ",ACCESS_TOKEN:" + token + ",addTimestamp:" + addTimestamp + ",USRIP:" + usrip);
                mc.sResult_Value = oDataSrc1.Set_WxToken(appid, token, addTimestamp);
                oDataSrc1.Commit();
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("更新微信公众平台TOKEN", "", fromIP, "Set_WxToken(更新微信公众平台TOKEN)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("更新微信公众平台TOKEN", "", fromIP, "Set_WxToken(更新微信公众平台TOKEN)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        #endregion

        #region  傭金

        [WebMethod (Description="邀請客人")]
        public String Invite_custom(string sJson, string id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            bool bResult = false;
            bool bValidEmail = false;
            bool bValidNum = false;
            long defaulti = 0;
            string sSubject = string.Empty;
            string sMailBody = string.Empty;
            string sResult = string.Empty;
            string from_user = string.Empty;
            String sJson_Tmp = string.Empty;
            invite_table head = new invite_table();
            IList<invite_content> body = new List<invite_content>();
            head = JsonConvert.DeserializeObject<invite_table>(sJson);
            String fromIP = HttpContext.Current.Request.UserHostAddress;
                try
                {
                    oLog.writeLine("邀请客人", "", fromIP, "Invite_custom(邀请客人)", APUtil.clsLog.enumMsgType.General, "sJson:" + sJson + ",id:" + id + ",logintype:" + logintype + ",sToken:" + sToken + ",usrip:" + usrip);
                    if (sJson == "" || id == "" || logintype == "" || sToken == "" || usrip == "")
                    {
                        mc.sResult_Value = "-3";
                        mc.sMsg_Value = "缺少必填参数";
                        sJson_Tmp = " {";
                        sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                        sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                        sJson_Tmp = sJson_Tmp + "}";
                        return sJson_Tmp;
                    }
                    oDataSrc1 = new clsDataSrc_cshap();
                    oDataSrc = new APUtil.clsDataSrc();
                    oDataSrc1.BeginTrans();
                    oDataSrc.BeginTrans();
                    bResult = oDataSrc1.Check_Token(id, logintype, sToken);
                    if (bResult == false)
                    {
                        mc.sResult_Value = "-2";
                        mc.sMsg_Value = "TOKEN验证失败";
                        sJson_Tmp = " {";
                        sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                        sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                        sJson_Tmp = sJson_Tmp + "}";
                        return sJson_Tmp;
                    }
                    DataTable table = new DataTable();
                    DataSet ds = new DataSet();
                    table.Columns.Add("referer_info", typeof(string));
                    table.Columns.Add("invite_result", typeof(string));
                    string a = head._accountid;
                    from_user = oDataSrc1.Get_CNAME(a);
                    if (from_user == "0")
                        from_user = "迷你储存";
                    for (int i = 0; i <= head._body.Count - 1; i++)
                    {
                        bValidEmail = false;
                        bValidNum = false;
                        //檢查傳入資料格式是否為EMAIL
                        if (oDataSrc1.IsValidEmail(head._body[i]._referer_info.Trim()))
                        {
                            bValidEmail = true;
                        }
                        else
                        {
                            bValidNum = long.TryParse(head._body[i]._referer_info.Trim(), out defaulti);
                            if (bValidNum)
                            {
                                //如果是數字,判斷長度是否度11位(中國手機號)
                                if (head._body[i]._referer_info.Trim().Length == 11)
                                    bValidNum = true;
                                else
                                    bValidNum = false;
                            }
                        }

                        //如果傳入資料格式為EMAIL 或 是手機號
                        if (bValidNum || bValidEmail)
                        {
                            //檢查是否傳入資料是否已經是會員
                            string re = oDataSrc.ACCOUNT_IS_EXIST(head._body[i]._referer_info.Trim());
                            if (re == "0")
                            {
                                if (oDataSrc1.IsValidEmail(head._body[i]._referer_info.Trim()))
                                {
                                    //寄出邀請信
                                    sSubject = "迷你储存-" + from_user + "邀请加入";
                                    sMailBody = "嗨~亲，你好 ";
                                    sMailBody = sMailBody + "</br><p>" + from_user + "开始使用云仓储的迷你储存了，很好的东东，也分享给你哦，快去看看吧。";
                                    sMailBody = sMailBody + "</br>请点击以下链接。立即加入我们，你有意外的收获啊。";
                                    sMailBody = sMailBody + "</br>";
                                    sMailBody = sMailBody + "</br><p><a href='www.minichucun.com/register.php?REFERER=" + a + "'><img src='http://60.248.34.96:8080/web/images/btn_invite.png'></a></p>";
                                    sMailBody = sMailBody + "</br><p></br>";
                                    sMailBody = sMailBody + "</br>点击或是扫一下我们的二维码即可下载我们的APP哦。</p>";
                                    sMailBody = sMailBody + "</br></br>";
                                    sMailBody = sMailBody + "</br><p><a href='http://weixin.qq.com/r/TnVIUFfEggr9rRMz9yBc'><img src='http://60.248.34.96:8080/web/images/QRcode-mail-105px-wechat.png' alt='关注迷你储存' height='105' width='105'></a>";
                                    sMailBody = sMailBody + "&nbsp;&nbsp;<a href='https://itunes.apple.com/us/app/mi-ni-chu-cun/id928994971?l=zh&ls=1&mt=8'><img src='http://60.248.34.96:8080/web/images/QRcode-mail-105px-apple.png' alt='迷你储存APP' height='105' width='105'></a></p></br>";
                                    sMailBody = sMailBody + "</br>";
                                    sMailBody = sMailBody + "</br><p>这里是迷你储存，“小创新，大改变”。你还在因为空间不足而烦恼";
                                    sMailBody = sMailBody + "吗？或者是还在为物品没有空间存放而困扰吗？如果是这样，就快来";
                                    sMailBody = sMailBody + "加入我们吧！更多空间，更好享受，更美生活。</p>";
                                    sMailBody = sMailBody + "</br><p>这是一封系统自动发送的邮件，请勿回复。</p>";
                                    sMailBody = sMailBody + "</br></br></br><p>迷你储存</p>";
                                    sMailBody = sMailBody + "</br></br><p>" + DateTime.Now.ToString("yyyy-MM-dd") + "</p>";
                                    sResult = oSend.sendMail(head._body[i]._referer_info.Trim(), "", sMailBody, sSubject); //发送电​​邮
                                    oLog.writeLine("邀请客人", "", fromIP, "Invite_custom(邀请客人)", APUtil.clsLog.enumMsgType.General, "sSubject:" + sSubject + ",sMailBody:" + sMailBody + ",邀请人:" + from_user);
                                    if (sResult != "0")
                                    {
                                        oDataSrc.Rollback();
                                        sJson_Tmp = " {";
                                        sJson_Tmp = sJson_Tmp + @"""Status"" : """ + "-1" + @""",";
                                        sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + sResult + @""" ";
                                        sJson_Tmp = sJson_Tmp + "}";
                                        oLog.writeLine("邀请客人", "", fromIP, "Invite_custom(邀请客人)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                                        return sJson_Tmp;
                                    }
                                    //寫入DataTable,回傳這些資料已寄出邀請
                                    table.Rows.Add(head._body[i]._referer_info.Trim(), "成功邀请");
                                }
                                else
                                {
                                    //發送邀請簡訊
                                    table.Rows.Add(head._body[i]._referer_info.Trim(), "尚未开放简讯邀请");
                                }
                            }
                            else
                            {
                                //寫入DataTable,回傳這些資料已經是會員
                                table.Rows.Add(head._body[i]._referer_info.Trim(), "已是会员");
                            }
                        }
                        else
                        {
                            //傳入資料格式非手機號或EMAIL則記錄LOG,並回傳
                            table.Rows.Add(head._body[i]._referer_info.Trim(), "传入资料格式不正确");
                        }
                    }

                    if (table != null)
                    {
                        DataTable temp = new DataTable();
                        temp = table.Copy();
                        temp.TableName = "Invite_custom";
                        ds.Tables.Add(temp);
                        mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                        oLog.writeLine("邀请客人", "", fromIP, "Invite_custom(邀请客人)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                    }
                    else
                    {
                        DataTable temp = new DataTable();
                        temp.TableName = "Invite_custom";
                        ds.Tables.Add(temp);
                        mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                        oLog.writeLine("邀请客人", "", fromIP, "Invite_custom(邀请客人)", APUtil.clsLog.enumMsgType.General, "Result:" + mc.sResult_Value);
                    }
                }
                catch (Exception ex)
                {
                    mc.sResult_Value = "-1";
                    mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                    //write log
                    oLog.writeLine("邀请客人", "", usrip, "Invite_custom(邀请客人)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                    oDataSrc1.RollBack();
                }
                finally { oDataSrc1 = null; }
                return mc.sResult_Value;
        }

        [WebMethod(Description = "销售奖金汇款帐号设定")]
        public String Set_ACCOUNT_BANK(string action, string account_id, string type, string bankname, string bankaccount, string bankaccountname,
            string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            String sJson_Tmp = String.Empty;
            DataTable dt = new DataTable();
            bool bResult = false;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oDataSrc1 = new clsDataSrc_cshap();
                oDataSrc1.BeginTrans();
                oLog.writeLine("销售奖金汇款帐号设定", "", fromIP, "Set_ACCOUNT_BANK(销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General,
                    "action:" + action + "," + "accountid:" + account_id + "," + "type:" + type + "," +
                    "bankname:" + bankname + "," + "bankaccount" + bankaccount + "," + "bankaccountname:" + bankaccountname +
                    "," + "logintype:" + logintype + ",sToken:" + sToken + ",usrip:" + usrip);

                if (action == "" || account_id == "" || type == "" || bankaccountname == "" || logintype == "" || sToken == "" || usrip == "")
                {
                    mc.sResult_Value = "-3";
                    mc.sMsg_Value = "缺少必填参数";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }

                bResult = oDataSrc1.Check_Token(account_id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("销售奖金汇款帐号设定", "", fromIP, "Set_ACCOUNT_BANK(销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }

                mc.sResult_Value = oDataSrc1.Set_ACCOUNT_BANK(action, account_id, type, bankname, bankaccount, bankaccountname);
                if (mc.sResult_Value == "0")
                    oDataSrc1.Commit();
                else
                    oDataSrc1.RollBack();
                
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("销售奖金汇款帐号设定", "", fromIP, "Set_Adresses(销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally
            {
                oDataSrc1 = null;
            }
            sJson_Tmp = " {";
            sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
            sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
            sJson_Tmp = sJson_Tmp + "}";
            oLog.writeLine("销售奖金汇款帐号设定", "", fromIP, "Set_Adresses(销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
            return sJson_Tmp;
        }

        [WebMethod(Description = "取得销售奖金汇款帐号设定")]
        public String Get_ACCOUNT_BANK(string account_id, string logintype, string sToken, string usrip)
        {
            MemberClass mc = new MemberClass();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            bool bResult = false;
            String sJson_Tmp = string.Empty;
            String fromIP = HttpContext.Current.Request.UserHostAddress;
            try
            {
                oLog.writeLine("取得销售奖金汇款帐号设定", "", fromIP, "Get_ACCOUNT_BANK(取得销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General,"ACCOUNT_ID:" + account_id + ",LOGINTYPE:" + logintype + ",sToken:" + sToken);
                oDataSrc1 = new clsDataSrc_cshap();

                if (account_id == "" || logintype == "" || sToken == "" || usrip == "")
                {
                    mc.sResult_Value = "-3";
                    mc.sMsg_Value = "缺少必填参数";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    return sJson_Tmp;
                }

                bResult = oDataSrc1.Check_Token(account_id, logintype, sToken);
                if (bResult == false)
                {
                    mc.sResult_Value = "-2";
                    mc.sMsg_Value = "TOKEN验证失败";
                    sJson_Tmp = " {";
                    sJson_Tmp = sJson_Tmp + @"""Status"" : """ + mc.sResult_Value + @""",";
                    sJson_Tmp = sJson_Tmp + @"""Msg"" : """ + mc.sMsg_Value + @""" ";
                    sJson_Tmp = sJson_Tmp + "}";
                    oLog.writeLine("取得销售奖金汇款帐号设定", "", fromIP, "Get_ACCOUNT_BANK(取得销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General, "return:" + sJson_Tmp);
                    return sJson_Tmp;
                }

                dt = oDataSrc1.Get_ACCOUNT_BANK(account_id);
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataTable temp = new DataTable();
                    temp = dt.Copy();
                    temp.TableName = "ACCOUNT_BANK";
                    ds.Tables.Add(temp);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得销售奖金汇款帐号设定", "", fromIP, "Get_ACCOUNT_BANK(取得销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General, "ACCOUNT_ID:" + account_id + ",回傳值:" + mc.sResult_Value);
                }
                else
                {
                    DataTable table = new DataTable();
                    table.TableName = "ACCOUNT_BANK";
                    ds.Tables.Add(table);
                    mc.sResult_Value = JsonConvert.SerializeObject(ds, Formatting.Indented);
                    oLog.writeLine("取得销售奖金汇款帐号设定", "", fromIP, "Get_ACCOUNT_BANK(取得销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General, "ACCOUNT_ID:" + account_id + ",回傳值:" + mc.sResult_Value);
                }
                return mc.sResult_Value;
            }
            catch (Exception ex)
            {
                mc.sResult_Value = "-1";
                mc.sMsg_Value = ex.Message.Replace(@"""", " ");
                //write log
                oLog.writeLine("取得销售奖金汇款帐号设定", "", fromIP, "Get_ACCOUNT_BANK(取得销售奖金汇款帐号设定)", APUtil.clsLog.enumMsgType.General, mc.sMsg_Value);
                oDataSrc1.RollBack();
            }
            finally { oDataSrc1 = null; }
            return mc.sResult_Value;
        }

        #endregion
    }

}